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

#apply_dc, #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.


183
184
185
186
187
188
189
190
# File 'lib/fox16/canvas.rb', line 183

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


180
181
182
# File 'lib/fox16/canvas.rb', line 180

def lineCap
  @lineCap
end

#lineJoinObject

Returns the value of attribute lineJoin


180
181
182
# File 'lib/fox16/canvas.rb', line 180

def lineJoin
  @lineJoin
end

#lineStyleObject

Returns the value of attribute lineStyle


180
181
182
# File 'lib/fox16/canvas.rb', line 180

def lineStyle
  @lineStyle
end

#lineWidthObject

Returns the value of attribute lineWidth


180
181
182
# File 'lib/fox16/canvas.rb', line 180

def lineWidth
  @lineWidth
end

#x1Object

Returns the value of attribute x1


181
182
183
# File 'lib/fox16/canvas.rb', line 181

def x1
  @x1
end

#x2Object

Returns the value of attribute x2


181
182
183
# File 'lib/fox16/canvas.rb', line 181

def x2
  @x2
end

#y1Object

Returns the value of attribute y1


181
182
183
# File 'lib/fox16/canvas.rb', line 181

def y1
  @y1
end

#y2Object

Returns the value of attribute y2


181
182
183
# File 'lib/fox16/canvas.rb', line 181

def y2
  @y2
end

Instance Method Details

#draw(dc) ⇒ Object


200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/fox16/canvas.rb', line 200

def draw(dc)
  apply_dc(dc) do
    # Save old values
    oldLineWidth = dc.lineWidth
    oldLineCap = dc.lineCap
    oldLineJoin = dc.lineJoin
    oldLineStyle = dc.lineStyle

    # Set properties for this line
    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
  end
end

#heightObject


196
197
198
# File 'lib/fox16/canvas.rb', line 196

def height
  0
end

#widthObject


192
193
194
# File 'lib/fox16/canvas.rb', line 192

def width
  0
end