Module: ImageVoodoo::Shapes
- Included in:
- ImageVoodoo
- Defined in:
- lib/image_voodoo/awt/shapes.rb
Instance Method Summary collapse
- #as_color(color) ⇒ Object
-
#rect(x, y, width, height, rgb, fill = true) ⇒ Object
AWT Draw a rectangle.
-
#rect_rounded(x, y, width, height, rgb, arc_width = 0, arc_height = 0, fill = true) ⇒ Object
AWT Draw a rounded rectangle.
-
#square(x, y, dim, rgb, fill = true) ⇒ Object
AWT Draw a square.
-
#square_rounded(x, y, dim, rgb, arc_width = 0, fill = true) ⇒ Object
AWT Draw a rounded square.
Instance Method Details
#as_color(color) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/image_voodoo/awt/shapes.rb', line 37 def as_color(color) paint do |g| old_color = g.color g.color = color yield g g.color = old_color end end |
#rect(x, y, width, height, rgb, fill = true) ⇒ Object
AWT Draw a rectangle
13 14 15 |
# File 'lib/image_voodoo/awt/shapes.rb', line 13 def rect(x, y, width, height, rgb, fill=true) rect_rounded(x, y, width, height, rgb, 0, 0, fill) end |
#rect_rounded(x, y, width, height, rgb, arc_width = 0, arc_height = 0, fill = true) ⇒ Object
AWT Draw a rounded rectangle
27 28 29 30 31 32 33 34 35 |
# File 'lib/image_voodoo/awt/shapes.rb', line 27 def rect_rounded(x, y, width, height, rgb, arc_width=0, arc_height=0, fill=true) as_color(ImageVoodoo.hex_to_color(rgb)) do |g| if fill g.fill_round_rect x, y, width, height, arc_width, arc_height else g.draw_round_rect x, y, width, height, arc_width, arc_height end end end |
#square(x, y, dim, rgb, fill = true) ⇒ Object
AWT Draw a square
6 7 8 |
# File 'lib/image_voodoo/awt/shapes.rb', line 6 def square(x, y, dim, rgb, fill=true) square_rounded(x, y, dim, rgb, 0, fill) end |
#square_rounded(x, y, dim, rgb, arc_width = 0, fill = true) ⇒ Object
AWT Draw a rounded square
20 21 22 |
# File 'lib/image_voodoo/awt/shapes.rb', line 20 def square_rounded(x, y, dim, rgb, arc_width=0, fill=true) rect_rounded(x,y, dim, dim, rgb, arc_width, arc_width, fill) end |