Class: Fox::Canvas::LineShape

Inherits:
Shape
  • Object
show all
Defined in:
lib/fox16/canvas.rb

Instance Attribute Summary collapse

Attributes inherited from Shape

#foreground, #selector, #target, #x, #y

Instance Method Summary collapse

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


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

#lineCapObject

Returns the value of attribute lineCap


173
174
175
# File 'lib/fox16/canvas.rb', line 173

def lineCap
  @lineCap
end

#lineJoinObject

Returns the value of attribute lineJoin


173
174
175
# File 'lib/fox16/canvas.rb', line 173

def lineJoin
  @lineJoin
end

#lineStyleObject

Returns the value of attribute lineStyle


173
174
175
# File 'lib/fox16/canvas.rb', line 173

def lineStyle
  @lineStyle
end

#lineWidthObject

Returns the value of attribute lineWidth


173
174
175
# File 'lib/fox16/canvas.rb', line 173

def lineWidth
  @lineWidth
end

#x1Object

Returns the value of attribute x1


174
175
176
# File 'lib/fox16/canvas.rb', line 174

def x1
  @x1
end

#x2Object

Returns the value of attribute x2


174
175
176
# File 'lib/fox16/canvas.rb', line 174

def x2
  @x2
end

#y1Object

Returns the value of attribute y1


174
175
176
# File 'lib/fox16/canvas.rb', line 174

def y1
  @y1
end

#y2Object

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

#heightObject


189
190
191
# File 'lib/fox16/canvas.rb', line 189

def height
  0
end

#widthObject


185
186
187
# File 'lib/fox16/canvas.rb', line 185

def width
  0
end