Class: GD2::Canvas::Polygon

Inherits:
Object
  • Object
show all
Defined in:
lib/gd2/canvas.rb

Direct Known Subclasses

FilledPolygon, OpenPolygon

Instance Method Summary collapse

Constructor Details

#initialize(points) ⇒ Polygon

Returns a new instance of Polygon


71
72
73
# File 'lib/gd2/canvas.rb', line 71

def initialize(points)
  @points = points
end

Instance Method Details

#draw(image, mode) ⇒ Object


75
76
77
78
79
80
# File 'lib/gd2/canvas.rb', line 75

def draw(image, mode)
  ::GD2::GD2FFI.send(draw_sym, image.image_ptr, @points.map { |point|
    point.coordinates.pack('i_i_')
  }.join(''), @points.length, mode.to_i)
  nil
end

#draw_symObject


82
83
84
# File 'lib/gd2/canvas.rb', line 82

def draw_sym
  :gdImagePolygon
end