class Dedalus::Elements::ImageGrid
Attributes
grid[RW]
redraw_tiles[RW]
scale[RW]
tile_class[RW]
tile_height[RW]
tile_width[RW]
tiles_path[RW]
Public Class Methods
description()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 69 def self.description "a grid of images" end
example_data()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 73 def self.example_data { tiles_path: "media/images/tiles.png", tile_width: 64, tile_height: 64, tile_class: "Dedalus::Elements::MapTile", #Elements::Sprite", scale: 0.2, grid: [ [ nil, 0, 2, 0, 1 ], [ 0, nil, 1, 0, 1 ], [ 0, 0, nil, 0, 1 ], [ 0, 1, 2, nil, 1 ], ] } end
Public Instance Methods
height()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 47 def height if grid grid.length * tile_height * scale else 0 end end
name()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 23 def name @name ||= 'an-image-grid' # a uniq id for recording end
no_image()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 65 def no_image Void.new(height: tile_height * scale, width: tile_width * scale) end
record?()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 31 def record? (grid && !grid.empty?) end
rerecord?()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 35 def rerecord? redraw_tiles end
show()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 7 def show if grid grid.map do |row_elements| row_elements.map do |grid_value| if grid_value sprite_for(grid_value) else no_image end end end else [] end end
sprite_for(frame)
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 55 def sprite_for(frame) tile_class.constantize.new( frame: frame, asset_width: tile_width, asset_height: tile_height, path: tiles_path, scale: scale ) end
width()
click to toggle source
# File lib/dedalus/elements/image_grid.rb, line 39 def width if grid && grid.first grid.first.length * tile_width * scale else 0 end end