Method: Pixelart::ImageComposite#_add
- Defined in:
- lib/pixelart/composite.rb
#_add(image) ⇒ Object
set / add tile
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/pixelart/composite.rb', line 85 def _add( image ) y, x = @tile_count.divmod( @tile_cols ) puts " [#{@tile_count}] @ (#{x}/#{y}) #{image.width}x#{image.height} (height x width)" ## note: only used if more than one background color specified ## needs to cycle through if @background_colors && @background_colors.size > 1 i = x + y*@tile_cols ## note: cycle through background color for now background_color = @background_colors[i % @background_colors.size] background = Image.new( @tile_width, @tile_height, background_color ) ## todo/chekc: use "raw" ChunkyPNG:Image here - why? why not? background.compose!( image ) image = background ## switch - make image with background new image end ## note: image.image - "unwrap" the "raw" ChunkyPNG::Image @img.compose!( image.image, x*@tile_width, y*@tile_height ) @tile_count += 1 end |