Class: Fox::Canvas::LineShape
Instance Attribute Summary collapse
-
#lineCap ⇒ Object
Returns the value of attribute lineCap.
-
#lineJoin ⇒ Object
Returns the value of attribute lineJoin.
-
#lineStyle ⇒ Object
Returns the value of attribute lineStyle.
-
#lineWidth ⇒ Object
Returns the value of attribute lineWidth.
-
#x1 ⇒ Object
Returns the value of attribute x1.
-
#x2 ⇒ Object
Returns the value of attribute x2.
-
#y1 ⇒ Object
Returns the value of attribute y1.
-
#y2 ⇒ Object
Returns the value of attribute y2.
Attributes inherited from Shape
#foreground, #selector, #target, #x, #y
Instance Method Summary collapse
- #draw(dc) ⇒ Object
- #height ⇒ Object
-
#initialize(x1, y1, x2, y2) ⇒ LineShape
constructor
A new instance of LineShape.
- #width ⇒ Object
Methods inherited from Shape
#bounds, #deselect, #disable, #draggable=, #draggable?, #drawOutline, #enable, #enabled?, #hide, #hit?, #makeControlPoints, #move, #position, #resize, #select, #selected?, #show, #visible?
Constructor Details
#initialize(x1, y1, x2, y2) ⇒ LineShape
Returns a new instance of LineShape.
176 177 178 179 180 181 182 183 |
# File 'lib/fox16/canvas.rb', line 176 def initialize(x1, y1, x2, y2) super(x1, y1) @x1, @y1, @x2, @y2 = x1, y1, x2, y2 @lineWidth = 1 @lineCap = CAP_NOT_LAST @lineJoin = JOIN_MITER @lineStyle = LINE_SOLID end |
Instance Attribute Details
#lineCap ⇒ Object
Returns the value of attribute lineCap.
173 174 175 |
# File 'lib/fox16/canvas.rb', line 173 def lineCap @lineCap end |
#lineJoin ⇒ Object
Returns the value of attribute lineJoin.
173 174 175 |
# File 'lib/fox16/canvas.rb', line 173 def lineJoin @lineJoin end |
#lineStyle ⇒ Object
Returns the value of attribute lineStyle.
173 174 175 |
# File 'lib/fox16/canvas.rb', line 173 def lineStyle @lineStyle end |
#lineWidth ⇒ Object
Returns the value of attribute lineWidth.
173 174 175 |
# File 'lib/fox16/canvas.rb', line 173 def lineWidth @lineWidth end |
#x1 ⇒ Object
Returns the value of attribute x1.
174 175 176 |
# File 'lib/fox16/canvas.rb', line 174 def x1 @x1 end |
#x2 ⇒ Object
Returns the value of attribute x2.
174 175 176 |
# File 'lib/fox16/canvas.rb', line 174 def x2 @x2 end |
#y1 ⇒ Object
Returns the value of attribute y1.
174 175 176 |
# File 'lib/fox16/canvas.rb', line 174 def y1 @y1 end |
#y2 ⇒ Object
Returns the value of attribute y2.
174 175 176 |
# File 'lib/fox16/canvas.rb', line 174 def y2 @y2 end |
Instance Method Details
#draw(dc) ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/fox16/canvas.rb', line 193 def draw(dc) # Save old values oldForeground = dc.foreground oldLineWidth = dc.lineWidth oldLineCap = dc.lineCap oldLineJoin = dc.lineJoin oldLineStyle = dc.lineStyle # Set properties for this line dc.foreground = foreground dc.lineWidth = lineWidth dc.lineCap = lineCap dc.lineJoin = lineJoin dc.lineStyle = lineStyle # Draw the line dc.drawLine(x1, y1, x2, y2) # Restore old properties dc.lineWidth = oldLineWidth dc.lineCap = oldLineCap dc.lineJoin = oldLineJoin dc.lineStyle = oldLineStyle dc.foreground = oldForeground end |
#height ⇒ Object
189 190 191 |
# File 'lib/fox16/canvas.rb', line 189 def height 0 end |
#width ⇒ Object
185 186 187 |
# File 'lib/fox16/canvas.rb', line 185 def width 0 end |