class Dedalus::Elements::Image
Attributes
invert_x[RW]
invert_y[RW]
overlay_color[RW]
padding[RW]
path[RW]
z_order[RW]
Public Class Methods
description()
click to toggle source
# File lib/dedalus/elements/image.rb, line 62 def self.description "an image" end
example_data()
click to toggle source
# 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
Public Instance Methods
asset()
click to toggle source
# File lib/dedalus/elements/image.rb, line 66 def asset @asset ||= Dedalus::ImageRepository.lookup(path) end
dimensions()
click to toggle source
# File lib/dedalus/elements/image.rb, line 46 def dimensions [ width, height ] end
height()
click to toggle source
# File lib/dedalus/elements/image.rb, line 42 def height 2*padding + (asset.height * scale) end
offset()
click to toggle source
# 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()
click to toggle source
# File lib/dedalus/elements/image.rb, line 22 def overlay_gosu_color clr = Palette.decode_color(overlay_color).to_gosu clr.alpha = 255 clr end
render()
click to toggle source
# 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 overlay_color asset.draw(x,y, z_order, x_scale, y_scale, overlay_gosu_color) else asset.draw(x,y, z_order, x_scale, y_scale) end end
scale()
click to toggle source
# File lib/dedalus/elements/image.rb, line 54 def scale @scale ||= 1.0 end
width()
click to toggle source
def z_order
@z_order ||= ZOrder::Foreground
end
# File lib/dedalus/elements/image.rb, line 38 def width 2*padding + (asset.width * scale) end