Class: Shape

Inherits:
Object
  • Object
show all
Includes:
CairoTools
Defined in:
lib/shape.rb

Instance Attribute Summary collapse

Attributes included from CairoTools

#bottom_margin, #canvas_height, #canvas_width, #left_margin, #preview, #right_margin, #surface, #top_margin

Instance Method Summary collapse

Methods included from CairoTools

#circular_text, #clip!, #clouds, #create_text_box, #dimensions, #draw_image, #draw_text_box, #generate_image, #get_pixel, #gradient, #linear_gradient, #load_image, #margin, #radial_gradient, #rounded_rectangle, #set_color, #shadow, #transform, #transparent!

Methods included from Color

#hsl, #rgb

Constructor Details

#initialize(name, width, height, proc) ⇒ Shape

Returns a new instance of Shape.



4
5
6
# File 'lib/shape.rb', line 4

def initialize(name, width, height, proc)
  @name, @width, @height, @proc = name, width, height, proc
end

Instance Attribute Details

#crObject (readonly)

Returns the value of attribute cr.



3
4
5
# File 'lib/shape.rb', line 3

def cr
  @cr
end

#heightObject (readonly)

Returns the value of attribute height.



3
4
5
# File 'lib/shape.rb', line 3

def height
  @height
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/shape.rb', line 3

def name
  @name
end

#procObject (readonly)

Returns the value of attribute proc.



3
4
5
# File 'lib/shape.rb', line 3

def proc
  @proc
end

#widthObject (readonly)

Returns the value of attribute width.



3
4
5
# File 'lib/shape.rb', line 3

def width
  @width
end

Instance Method Details

#draw(cr, x, y) ⇒ Object



8
9
10
11
12
13
# File 'lib/shape.rb', line 8

def draw(cr, x, y)
  @cr = cr
  transform cr.matrix.translate(x, y) do
    instance_eval(&proc)
  end
end