Class: Oekaki::Star
Instance Attribute Summary
Attributes inherited from Tool
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(fill, x1, y1, x2, y2, color) ⇒ Star
constructor
A new instance of Star.
Methods inherited from Tool
#arc, #circle, #clear, #color, #get_pic, #get_window_size, #line, #lines, #load_pic, #point, #polygon, #rectangle, #save_pic, #show_pic, #star, #text, #timer_stop
Constructor Details
#initialize(fill, x1, y1, x2, y2, color) ⇒ Star
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/oekaki.rb', line 148 def initialize(fill, x1, y1, x2, y2, color) @fill = fill @o = []; @a = []; @b = [] @o[0], @o[1] = x1, y1 @a[0] = Vector[x2 - x1, y1 - y2] |
Instance Method Details
#draw ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/oekaki.rb', line 170 def draw if @fill 5.times {|i| draw_triangle(i)} ar = [] 5.times {|i| ar << @b[i].to_w(@o)} polygon(@fill, ar) else ar = [] 5.times {|i| ar << @a[i].to_w(@o); ar << @b[i].to_w(@o)} polygon(@fill, ar) end end |