class Glimmer::Gtk::Shape::Polygon

Represents a polygon (a closed path consisting of lines)

Public Instance Methods

draw_shape(drawing_area_widget, cairo_context) click to toggle source
# File lib/glimmer/gtk/shape/polygon.rb, line 65
def draw_shape(drawing_area_widget, cairo_context)
  cairo_context.new_path
  the_points = points
  the_points.each_with_index do |point, i|
    if i == 0
      cairo_context.move_to(*point)
    else
      cairo_context.line_to(*point)
    end
  end
  cairo_context.close_path unless the_points.last == the_points.first
end
points() click to toggle source
# File lib/glimmer/gtk/shape/polygon.rb, line 78
def points
  the_points = []
  @args.each_with_index do |arg, i|
    if i.even?
      the_points << [arg]
    else
      the_points.last << arg
    end
  end
  the_points
end