Class: Glimmer::Gtk::Shape::Path
Overview
Represents Gtk paths consisting of operations: move_to, line_to, curve_to, rel_move_to, rel_line_to, rel_curve_to, and close_path
Constant Summary
SHAPE_FILL_PROPERTIES, SHAPE_FONT_PROPERTIES, SHAPE_GENERAL_PROPERTIES, SHAPE_STROKE_PROPERTIES
Instance Attribute Summary collapse
#args, #block, #clip, #fill, #keyword, #parent, #stroke
Instance Method Summary
collapse
#apply_property, constant_symbol, #content, create, descendant_keyword_constant_map, #draw, #draw_clip, #draw_fill, #draw_font, #draw_stroke, exist?, keyword, map_descendant_keyword_constants_for, #method_missing, one_based_color_rgb, #post_add_content, reset_descendant_keyword_constant_map, #respond_to?, set_source_dynamically, shape_class, #window_proxy
#apply_transforms, #rotate, #scale, #translate
Constructor Details
#initialize(keyword, parent, args, &block) ⇒ Path
Returns a new instance of Path.
67
68
69
70
|
# File 'lib/glimmer/gtk/shape/path.rb', line 67
def initialize(keyword, parent, args, &block)
super
@drawing_operations = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Glimmer::Gtk::Shape
Instance Attribute Details
#drawing_operations ⇒ Object
Returns the value of attribute drawing_operations.
65
66
67
|
# File 'lib/glimmer/gtk/shape/path.rb', line 65
def drawing_operations
@drawing_operations
end
|
Instance Method Details
#arc(*args) ⇒ Object
102
103
104
|
# File 'lib/glimmer/gtk/shape/path.rb', line 102
def arc(*args)
@drawing_operations << [:arc, args]
end
|
#arc_negative(*args) ⇒ Object
106
107
108
|
# File 'lib/glimmer/gtk/shape/path.rb', line 106
def arc_negative(*args)
@drawing_operations << [:arc_negative, args]
end
|
#child_paths ⇒ Object
76
77
78
|
# File 'lib/glimmer/gtk/shape/path.rb', line 76
def child_paths
@child_paths ||= []
end
|
#close_path ⇒ Object
158
159
160
|
# File 'lib/glimmer/gtk/shape/path.rb', line 158
def close_path
@drawing_operations << [:close_path]
end
|
#curve_to(*args) ⇒ Object
142
143
144
|
# File 'lib/glimmer/gtk/shape/path.rb', line 142
def curve_to(*args)
@drawing_operations << [:curve_to, args]
end
|
#draw_shape(drawing_area_widget, cairo_context) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/glimmer/gtk/shape/path.rb', line 80
def draw_shape(drawing_area_widget, cairo_context)
previous_matrix = cairo_context.matrix
apply_transforms(cairo_context, target: :shape)
cairo_context.new_path
@drawing_operations.each do |drawing_operation_details|
cairo_context.send(drawing_operation_details[0], *drawing_operation_details[1])
end
child_paths.each do |child|
cairo_context.new_sub_path
child.drawing_operations.each do |drawing_operation_details|
cairo_context.send(drawing_operation_details[0], *drawing_operation_details[1])
end
end
cairo_context.set_matrix(previous_matrix)
end
|
#glyph_path(*args) ⇒ Object
126
127
128
|
# File 'lib/glimmer/gtk/shape/path.rb', line 126
def glyph_path(*args)
@drawing_operations << [:text_path, args]
end
|
#line_to(*args) ⇒ Object
138
139
140
|
# File 'lib/glimmer/gtk/shape/path.rb', line 138
def line_to(*args)
@drawing_operations << [:line_to, args]
end
|
#move_to(*args) ⇒ Object
134
135
136
|
# File 'lib/glimmer/gtk/shape/path.rb', line 134
def move_to(*args)
@drawing_operations << [:move_to, args]
end
|
#new_sub_path(*args) ⇒ Object
TODO look into a way to generalize the declaration of the methods below (or perform code reuse)
98
99
100
|
# File 'lib/glimmer/gtk/shape/path.rb', line 98
def new_sub_path(*args)
@drawing_operations << [:new_sub_path, args]
end
|
#post_initialize_child(child) ⇒ Object
72
73
74
|
# File 'lib/glimmer/gtk/shape/path.rb', line 72
def post_initialize_child(child)
child_paths << child if child.is_a?(Path)
end
|
#rectangle(*args) ⇒ Object
110
111
112
|
# File 'lib/glimmer/gtk/shape/path.rb', line 110
def rectangle(*args)
@drawing_operations << [:rectangle, args]
end
|
#rel_curve_to(*args) ⇒ Object
154
155
156
|
# File 'lib/glimmer/gtk/shape/path.rb', line 154
def rel_curve_to(*args)
@drawing_operations << [:rel_curve_to, args]
end
|
#rel_line_to(*args) ⇒ Object
150
151
152
|
# File 'lib/glimmer/gtk/shape/path.rb', line 150
def rel_line_to(*args)
@drawing_operations << [:rel_line_to, args]
end
|
#rel_move_to(*args) ⇒ Object
146
147
148
|
# File 'lib/glimmer/gtk/shape/path.rb', line 146
def rel_move_to(*args)
@drawing_operations << [:rel_move_to, args]
end
|
#rounded_rectangle(*args) ⇒ Object
114
115
116
|
# File 'lib/glimmer/gtk/shape/path.rb', line 114
def rounded_rectangle(*args)
@drawing_operations << [:rounded_rectangle, args]
end
|
#show_glyphs(*args) ⇒ Object
130
131
132
|
# File 'lib/glimmer/gtk/shape/path.rb', line 130
def show_glyphs(*args)
@drawing_operations << [:show_text, args]
end
|
#show_text(*args) ⇒ Object
122
123
124
|
# File 'lib/glimmer/gtk/shape/path.rb', line 122
def show_text(*args)
@drawing_operations << [:show_text, args]
end
|
#text_path(*args) ⇒ Object
118
119
120
|
# File 'lib/glimmer/gtk/shape/path.rb', line 118
def text_path(*args)
@drawing_operations << [:text_path, args]
end
|