class Line

line.rb

Attributes

c1[R]
c2[R]
c3[R]
c4[R]
color[R]
qx1[R]
qx2[R]
qx3[R]
qx4[R]
qy1[R]
qy2[R]
qy3[R]
qy4[R]
w[R]
x1[R]
x2[R]
y1[R]
y2[R]

Public Class Methods

new(x1, y1, x2, y2, w, c="white", visible=true) click to toggle source
# File lib/r2d/line.rb, line 9
def initialize(x1, y1, x2, y2, w, c="white", visible=true)
  @x1, @y1, @x2, @y2, @w, @color = x1, y1, x2, y2, w, c
  update_coords(x1, y1, x2, y2, w)
  update_color(c)
  if visible then add end
end

Public Instance Methods

add() click to toggle source
# File lib/r2d/line.rb, line 46
def add
  R2D::Window.add(self)
end
color=(c) click to toggle source
# File lib/r2d/line.rb, line 41
def color=(c)
  @color = c
  update_color(c)
end
hide() click to toggle source
# File lib/r2d/line.rb, line 55
def hide; remove end
remove() click to toggle source
# File lib/r2d/line.rb, line 50
def remove
  R2D::Window.remove(self)
end
show() click to toggle source
# File lib/r2d/line.rb, line 54
def show; add end
w=(w) click to toggle source
# File lib/r2d/line.rb, line 36
def w=(w)
  @w = w
  update_coords(@x1, @y1, @x2, @y2, w)
end
x1=(x1) click to toggle source
# File lib/r2d/line.rb, line 16
def x1=(x1)
  @x1 = x1
  update_coords(x1, @y1, @x2, @y2, @w)
end
x2=(x2) click to toggle source
# File lib/r2d/line.rb, line 26
def x2=(x2)
  @x2 = x2
  update_coords(@x1, @y1, x2, @y2, @w)
end
y1=(y1) click to toggle source
# File lib/r2d/line.rb, line 21
def y1=(y1)
  @y1 = y1
  update_coords(@x1, y1, @x2, @y2, @w)
end
y2=(y2) click to toggle source
# File lib/r2d/line.rb, line 31
def y2=(y2)
  @y2 = y2
  update_coords(@x1, @y1, @x2, y2, @w)
end

Private Instance Methods

update_color(c) click to toggle source
# File lib/r2d/line.rb, line 70
def update_color(c)
  @c1 = R2D::Color.new(c)
  @c2 = R2D::Color.new(c)
  @c3 = R2D::Color.new(c)
  @c4 = R2D::Color.new(c)
end
update_coords(x1, y1, x2, y2, w) click to toggle source
# File lib/r2d/line.rb, line 59
def update_coords(x1, y1, x2, y2, w)
  @qx1 = x1
  @qy1 = y1 - w/2
  @qx2 = x2
  @qy2 = y2 - w/2
  @qx3 = x1
  @qy3 = y1 + w/2
  @qx4 = x2
  @qy4 = y2 + w/2
end