lib/chunky_png/canvas/drawing.rb
# Draws a rectangle on the canvas, using two control points.
#
# @param [Integer] x0 The x-coordinate of the first control point.
# @param [Integer] y0 The y-coordinate of the first control point.
# @param [Integer] x1 The x-coordinate of the second control point.
# @param [Integer] y1 The y-coordinate of the second control point.
# @param [Integer] stroke_color The line color to use for this rectangle.
# @param [Integer] fill_color The fill color to use for this rectangle.
# @return [ChunkyPNG::Canvas] Itself, with the rectangle drawn.
Draws a rectangle on the canvas, using two control points.
Draws a rectangle on the canvas using two control points .
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)
        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
        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)
        self
      end
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 ) 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 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 ) self end
Draws a rectangle on the canvas, using two control points.
Draws a rectangle on the canvas using two control points .
# Fill # Stroke
Itself, with the rectangle drawn.
Itself with the rectangle drawn .
ChunkyPNG::Canvas
x0
<not_specific>
y0
<not_specific>
x1
<not_specific>
y1
<not_specific>
stroke_color
<not_specific>
fill_color
<not_specific>
<not_specific>
fill_color The fill color to use for this rectangle.
fill_color The fill color to use for this rectangle .