class Fox::FXGLLine
OpenGL line object
Attributes
fm[RW]
Starting point for line [FXGLPoint]
to[RW]
End point for line [FXGLPoint]
Public Class Methods
new(*args)
click to toggle source
Return an initialized FXGLLine
instance.
If no arguments are passed to new, the initial starting and ending points for the line are (-0.5, 0.0, 0.0) and (0.5, 0.0, 0.0), respectively. You can specify different initial start and end points by passing in another FXGLLine
instance from which to copy the start and end point values, e.g.
aLine = FXGLLine.new(anotherLine)
or by passing in the x, y and z coordinates individually:
aLine = FXGLLine.new(x0, y0, z0, x1, y1, z1)
Calls superclass method
Fox::FXGLObject::new
# File lib/fox16/glshapes.rb, line 93 def initialize(*args) super() if args.length == 0 @fm = FXGLPoint.new(-0.5, 0.0, 0.0) @to = FXGLPoint.new( 0.5, 0.0, 0.0) elsif args.length == 1 @fm = args[0].fm @to = args[0].to else @fm = FXGLPoint.new(args[0], args[1], args[2]) @to = FXGLPoint.new(args[3], args[4], args[5]) end end
Public Instance Methods
bounds()
click to toggle source
Return the bounding box (an FXRangef
instance) for this line.
# File lib/fox16/glshapes.rb, line 110 def bounds FXRangef.new([@fm.pos[0], @to.pos[0]].min, [@fm.pos[0], @to.pos[0]].max, [@fm.pos[1], @to.pos[1]].min, [@fm.pos[1], @to.pos[1]].max, [@fm.pos[2], @to.pos[2]].min, [@fm.pos[2], @to.pos[2]].max) end
draw(viewer)
click to toggle source
Draw this line into viewer (an FXGLViewer
instance).
# File lib/fox16/glshapes.rb, line 122 def draw(viewer) GL::Color(1.0, 0.0, 0.0) GL::PointSize(HANDLE_SIZE) GL::Begin(GL::LINES) GL::Vertex(@fm.pos) GL::Vertex(@to.pos) GL::End() end
hit(viewer)
click to toggle source
Perform hit-test for this line in viewer (an FXGLViewer
instance).
# File lib/fox16/glshapes.rb, line 134 def hit(viewer) GL::Begin(GL::LINES) GL::Vertex(@fm.pos) GL::Vertex(@to.pos) GL::End() end