class ChunkyPNG::Canvas
def initialize(width, height, initial = ChunkyPNG::Color::TRANSPARENT)
-
initial
(Array
) -- The initial pizel values. Must be an -
height
(Integer
) -- The height in pixels of this canvas -
width
(Integer
) -- The width in pixels of this canvas -
background_color
(Integer, ...
) -- The initial background color of -
height
(Integer
) -- The height in pixels of this canvas -
width
(Integer
) -- The width in pixels of this canvas
Overloads:
-
initialize(width, height, initial)
-
initialize(width, height, background_color)
def initialize(width, height, initial = ChunkyPNG::Color::TRANSPARENT) @width, @height = width, height if initial.is_a?(Array) pixel_count = width * height unless initial.length == pixel_count raise ArgumentError, "The initial array should have #{width}x#{height} = #{pixel_count} elements!" end @pixels = initial else @pixels = Array.new(width * height, ChunkyPNG::Color.parse(initial)) end end