class CTioga2::Graphics::Types::Point
Represents a given Point
for Tioga. Its coordinates are BaseCoordinate
objects.
Attributes
x[RW]
The X coordinate, a BaseCoordinate
object
y[RW]
The Y coordinate, a BaseCoordinate
object
Public Class Methods
from_text(text, default = :figure)
click to toggle source
Creates a Point
object from a text specification. Splits up the text at a comma and
# File lib/ctioga2/graphics/types/point.rb, line 105 def self.from_text(text, default = :figure) vals = text.split(/\s*,\s*/) if vals.size != 2 raise "Should really have two values: #{text}" end coord = Point.new coord.x = BaseCoordinate.from_text(vals[0], :x, default) coord.y = BaseCoordinate.from_text(vals[1], :y, default) return coord end
new(x = nil, y = nil, type = :figure)
click to toggle source
Creates a Point
with the given coordinates (of type type, see BaseCoordinate
for more information).
# File lib/ctioga2/graphics/types/point.rb, line 86 def initialize(x = nil, y = nil, type = :figure) if x && y @x = BaseCoordinate.new(type, x, :x) @y = BaseCoordinate.new(type, y, :y) end end
Public Instance Methods
to_figure_xy(t)
click to toggle source
Converts the point to figure coordinates.
# File lib/ctioga2/graphics/types/point.rb, line 94 def to_figure_xy(t) return [@x.to_figure(t), @y.to_figure(t)] end
to_frame_xy(t)
click to toggle source
Converts the points to frame coordinates.
# File lib/ctioga2/graphics/types/point.rb, line 99 def to_frame_xy(t) return [@x.to_frame(t), @y.to_frame(t)] end