rubydraw 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rubydraw/flags.rb +0 -0
- data/lib/rubydraw/mouse_state.rb +7 -2
- data/lib/rubydraw/surface.rb +27 -0
- metadata +2 -2
data/lib/rubydraw/flags.rb
CHANGED
File without changes
|
data/lib/rubydraw/mouse_state.rb
CHANGED
@@ -21,9 +21,14 @@ module Rubydraw
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
#
|
25
|
-
def self.
|
24
|
+
# Returns the current mouse condition.
|
25
|
+
def self.info
|
26
26
|
state = SDL.GetMouseState
|
27
27
|
MouseState.new(state[0], Point[state[1], state[2]])
|
28
28
|
end
|
29
|
+
|
30
|
+
# Returns the current mouse position.
|
31
|
+
def self.position
|
32
|
+
info.position
|
33
|
+
end
|
29
34
|
end
|
data/lib/rubydraw/surface.rb
CHANGED
@@ -53,6 +53,10 @@ module Rubydraw
|
|
53
53
|
@sdl_surface.h
|
54
54
|
end
|
55
55
|
|
56
|
+
def size
|
57
|
+
Point[width, height]
|
58
|
+
end
|
59
|
+
|
56
60
|
# Fills this surface with the given color.
|
57
61
|
def fill(color)
|
58
62
|
SDL.FillRect(@sdl_surface, nil, color.to_i(:surface))
|
@@ -123,6 +127,8 @@ module Rubydraw
|
|
123
127
|
# information.
|
124
128
|
def basic_set_pix(point, new_color)
|
125
129
|
color = new_color.to_i(:surface)
|
130
|
+
color = 0xff_ff_ff
|
131
|
+
puts color
|
126
132
|
|
127
133
|
bpp = @sdl_surface.format.BytesPerPixel
|
128
134
|
p = @sdl_surface.pixels + (point.y * @sdl_surface.pitch + point.x * bpp)
|
@@ -183,6 +189,27 @@ module Rubydraw
|
|
183
189
|
ary
|
184
190
|
end
|
185
191
|
|
192
|
+
# Flip the surface on an axis.
|
193
|
+
def flip(axis)
|
194
|
+
axis = axis.to_sym
|
195
|
+
if axis == :horizontal
|
196
|
+
pixels.each {
|
197
|
+
|color, x, y|
|
198
|
+
set_pixel(Point[x, height - y], color)
|
199
|
+
}
|
200
|
+
return self
|
201
|
+
end
|
202
|
+
if axis == :vertical
|
203
|
+
pixels.each {
|
204
|
+
|color, x, y|
|
205
|
+
set_pixel(Point[width - x, y], color)
|
206
|
+
}
|
207
|
+
return self
|
208
|
+
end
|
209
|
+
# Only get here if no axis mode was matched.
|
210
|
+
raise ArgumentError, "Unknown flip mode: \"#{axis}\""
|
211
|
+
end
|
212
|
+
|
186
213
|
# Returns the area of this surface; e.g. if +width+ were 5 and +height+ were
|
187
214
|
# 4, this method would return 20.
|
188
215
|
def area
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rubydraw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- J. Wostenberg
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-20 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|