Class: Glimmer::Gtk::Shape::Polygon

Inherits:
Glimmer::Gtk::Shape show all
Defined in:
lib/glimmer/gtk/shape/polygon.rb

Overview

Represents a polygon (a closed path consisting of lines)

Constant Summary

Constants inherited from Glimmer::Gtk::Shape

SHAPE_FILL_PROPERTIES, SHAPE_FONT_PROPERTIES, SHAPE_GENERAL_PROPERTIES, SHAPE_STROKE_PROPERTIES

Instance Attribute Summary

Attributes inherited from Glimmer::Gtk::Shape

#args, #block, #clip, #fill, #keyword, #parent, #stroke

Instance Method Summary collapse

Methods inherited from Glimmer::Gtk::Shape

#apply_property, constant_symbol, #content, create, descendant_keyword_constant_map, #draw, #draw_clip, #draw_fill, #draw_font, #draw_stroke, exist?, #initialize, keyword, map_descendant_keyword_constants_for, #method_missing, one_based_color_rgb, #post_add_content, #post_initialize_child, reset_descendant_keyword_constant_map, #respond_to?, set_source_dynamically, shape_class, #window_proxy

Methods included from Transformable

#apply_transforms, #initialize, #rotate, #scale, #translate

Constructor Details

This class inherits a constructor from Glimmer::Gtk::Shape

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::Gtk::Shape

Instance Method Details

#draw_shape(drawing_area_widget, cairo_context) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
# 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

#pointsObject



78
79
80
81
82
83
84
85
86
87
88
# 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