module ChunkyPNG::Canvas::Drawing
def rect(x0, y0, x1, y1, stroke_color = ChunkyPNG::Color::BLACK, fill_color = ChunkyPNG::Color::TRANSPARENT)
-
(ChunkyPNG::Canvas)
- Itself, with the rectangle drawn.
Parameters:
-
fill_color
(Integer
) -- The fill color to use for this rectangle. -
stroke_color
(Integer
) -- The line color to use for this rectangle. -
y1
(Integer
) -- The y-coordinate of the second control point. -
x1
(Integer
) -- The x-coordinate of the second control point. -
y0
(Integer
) -- The y-coordinate of the first control point. -
x0
(Integer
) -- The x-coordinate of the first control point.
def rect(x0, y0, x1, y1, stroke_color = ChunkyPNG::Color::BLACK, fill_color = ChunkyPNG::Color::TRANSPARENT) stroke_color = ChunkyPNG::Color.parse(stroke_color) fill_color = ChunkyPNG::Color.parse(fill_color) # Fill unless fill_color == ChunkyPNG::Color::TRANSPARENT [x0, x1].min.upto([x0, x1].max) do |x| [y0, y1].min.upto([y0, y1].max) do |y| compose_pixel(x, y, fill_color) end end end # Stroke line(x0, y0, x0, y1, stroke_color, false) line(x0, y1, x1, y1, stroke_color, false) line(x1, y1, x1, y0, stroke_color, false) line(x1, y0, x0, y0, stroke_color, false) return self end