Class: Clogs::Star
Instance Attribute Summary
Attributes inherited from Drawable
#abs_x, #abs_y, #children, #height, #parent, #shoes_linkable_id, #styles, #width, #x, #y
Instance Method Summary
collapse
Methods inherited from ArtDrawable
#context_style, #draw_context, #fill_paint, #left, #opaque, #paint, #parent_content_width, #positioned?, #rotation, #stroke_paint, #strokewidth, #top
Methods inherited from Drawable
#add_child, #app, #clickable?, #contains?, #destroy_self, #each_peer, #focus_gained, #focus_lost, #focusable?, for_shoes_class, #hidden?, #initialize, #margin, #needs_layout!, #notify, #on_click, #on_key, #on_mouse_move, #on_release, #paint, #positioned?, #properties_changed, #redraw!, #remove_child, #requested_height, #requested_width, #set_parent, #style
Instance Method Details
#draw(painter, x, y) ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/clogs/drawables/shapes.rb', line 165
def draw(painter, x, y)
cx = x + outer
cy = y + outer
painter.draw(fill: fill_paint, stroke: stroke_paint, thickness: strokewidth) do |p|
(0...(points * 2)).each do |i|
r = i.even? ? outer : inner
angle = -Math::PI / 2 + i * Math::PI / points
px = cx + r * Math.cos(angle)
py = cy + r * Math.sin(angle)
i.zero? ? p.move_to(px, py) : p.line_to(px, py)
end
p.close
end
end
|
#inner ⇒ Object
157
158
159
|
# File 'lib/clogs/drawables/shapes.rb', line 157
def inner
(style(:inner) || 50).to_f
end
|
#measure(_available_width) ⇒ Object
161
162
163
|
# File 'lib/clogs/drawables/shapes.rb', line 161
def measure(_available_width)
@width = @height = (outer * 2).round
end
|
#outer ⇒ Object
153
154
155
|
# File 'lib/clogs/drawables/shapes.rb', line 153
def outer
(style(:outer) || 100).to_f
end
|
#points ⇒ Object
149
150
151
|
# File 'lib/clogs/drawables/shapes.rb', line 149
def points
(style(:points) || 10).to_i
end
|