Class: Dedalus::Elements::Image
- Inherits:
-
Atom
- Object
- Dedalus::Element
- Atom
- Dedalus::Elements::Image
- Defined in:
- lib/dedalus/elements/image.rb
Instance Attribute Summary collapse
-
#invert_x ⇒ Object
Returns the value of attribute invert_x.
-
#invert_y ⇒ Object
Returns the value of attribute invert_y.
-
#overlay_color ⇒ Object
Returns the value of attribute overlay_color.
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#path ⇒ Object
Returns the value of attribute path.
-
#z_order ⇒ Object
Returns the value of attribute z_order.
Attributes inherited from Dedalus::Element
#background_color, #color, #height_percent, #margin, #position, #shown, #width_percent
Class Method Summary collapse
Instance Method Summary collapse
- #asset ⇒ Object
- #dimensions ⇒ Object
- #height ⇒ Object
- #offset ⇒ Object
- #overlay_gosu_color ⇒ Object
- #render ⇒ Object
- #scale ⇒ Object
-
#width ⇒ Object
def z_order @z_order ||= ZOrder::Foreground end.
Methods inherited from Dedalus::Element
#big_font, #code_font, #draw_bounding_box, #font, #huge_font, #initialize, #record?, #tiny_font, #view, #window
Constructor Details
This class inherits a constructor from Dedalus::Element
Instance Attribute Details
#invert_x ⇒ Object
Returns the value of attribute invert_x.
4 5 6 |
# File 'lib/dedalus/elements/image.rb', line 4 def invert_x @invert_x end |
#invert_y ⇒ Object
Returns the value of attribute invert_y.
4 5 6 |
# File 'lib/dedalus/elements/image.rb', line 4 def invert_y @invert_y end |
#overlay_color ⇒ Object
Returns the value of attribute overlay_color.
4 5 6 |
# File 'lib/dedalus/elements/image.rb', line 4 def @overlay_color end |
#padding ⇒ Object
Returns the value of attribute padding.
4 5 6 |
# File 'lib/dedalus/elements/image.rb', line 4 def padding @padding end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/dedalus/elements/image.rb', line 4 def path @path end |
#z_order ⇒ Object
Returns the value of attribute z_order.
4 5 6 |
# File 'lib/dedalus/elements/image.rb', line 4 def z_order @z_order end |
Class Method Details
.description ⇒ Object
62 63 64 |
# File 'lib/dedalus/elements/image.rb', line 62 def self.description "an image" end |
.example_data ⇒ Object
58 59 60 |
# File 'lib/dedalus/elements/image.rb', line 58 def self.example_data { path: "media/images/cosmos.jpg", scale: 0.2, invert_y: true, invert_x: true } end |
Instance Method Details
#asset ⇒ Object
66 67 68 |
# File 'lib/dedalus/elements/image.rb', line 66 def asset @asset ||= Dedalus::ImageRepository.lookup(path) end |
#dimensions ⇒ Object
46 47 48 |
# File 'lib/dedalus/elements/image.rb', line 46 def dimensions [ width, height ] end |
#height ⇒ Object
42 43 44 |
# File 'lib/dedalus/elements/image.rb', line 42 def height 2*padding + (asset.height * scale) end |
#offset ⇒ Object
28 29 30 31 32 |
# File 'lib/dedalus/elements/image.rb', line 28 def offset ox = invert_x ? width : 0 oy = invert_y ? height : 0 [ ox, oy ] end |
#overlay_gosu_color ⇒ Object
22 23 24 25 26 |
# File 'lib/dedalus/elements/image.rb', line 22 def clr = Palette.decode_color().to_gosu clr.alpha = 255 clr end |
#render ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dedalus/elements/image.rb', line 6 def render x0,y0 = *position ox,oy = *offset x_scale = invert_x ? -scale : scale y_scale = invert_y ? -scale : scale x,y = x0 + padding + ox, y0 + padding + oy if asset.draw(x,y, z_order, x_scale, y_scale, ) else asset.draw(x,y, z_order, x_scale, y_scale) end end |
#scale ⇒ Object
54 55 56 |
# File 'lib/dedalus/elements/image.rb', line 54 def scale @scale ||= 1.0 end |
#width ⇒ Object
def z_order @z_order ||= ZOrder::Foreground end
38 39 40 |
# File 'lib/dedalus/elements/image.rb', line 38 def width 2*padding + (asset.width * scale) end |