class CooCoo::Drawing::Canvas
Attributes
fill_color[RW]
stroke_color[RW]
Public Instance Methods
blit(img, x, y)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 37 def blit(img, x, y) self end
circle(x, y, r)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 33 def circle(x, y, r) self end
fill_color=(c)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 9 def fill_color=(c) @fill_color = ChunkyPNG::Color.parse(c) end
flush()
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 17 def flush self end
line(x1, y1, x2, y2)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 21 def line(x1, y1, x2, y2) self end
rect(x, y, w, h)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 29 def rect(x, y, w, h) self end
stroke(points)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 25 def stroke(points) self end
stroke_color=(c)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 13 def stroke_color=(c) @stroke_color = ChunkyPNG::Color.parse(c) end
text(txt, x, y, font, size, style = nil)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 41 def text(txt, x, y, font, size, style = nil) self end
Protected Instance Methods
chunky_to_vector(img, grayscale)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 57 def chunky_to_vector(img, grayscale) f = if grayscale method(:to_grayscale) else method(:color_components) end Vector[img.pixels.collect(&f).flatten] end
color_components(c)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 46 def color_components(c) [ ChunkyPNG::Color.r(c), ChunkyPNG::Color.g(c), ChunkyPNG::Color.b(c) ] end
to_grayscale(c)
click to toggle source
# File lib/coo-coo/drawing/canvas.rb, line 53 def to_grayscale(c) ChunkyPNG::Color.r(ChunkyPNG::Color.to_grayscale(c)) end