class Vissen::Output::Point
Points are simple two dimensional coordinates with an x and y component. They are used by the `CloudContext` to keep track of the position of its points.
Attributes
@return [Array<Float>] an array containing the x and y coordinates of
the point.
@return [Array<Float>] an array containing the x and y coordinates of
the point.
Public Class Methods
Coerce objects into points.
@param obj [#to_a] the object to be coerced into a `Point`. @param args (see initialize) @return [Point] a new `Point` object.
# File lib/vissen/output/point.rb, line 51 def from(obj, **args) new(*obj.to_a, **args) end
@param x [Numeric] the x coordinate of the point. @param y [Numeric] the y coordinate of the point. @param scale [Numeric] a scale factor to apply to the coordinates.
# File lib/vissen/output/point.rb, line 18 def initialize(x, y, scale: 1.0) @position = [x * scale, y * scale] end
Public Instance Methods
Prevents the position from being changed.
@return [self]
# File lib/vissen/output/point.rb, line 35 def freeze @position.freeze super end
@return [String] a string representation of the point.
# File lib/vissen/output/point.rb, line 41 def inspect format('(%0.2f,%0.2f)', *@position) end
@return [Float] the x coordinate of the point.
# File lib/vissen/output/point.rb, line 23 def x @position[0] end
@return [Float] the y coordinate of the point.
# File lib/vissen/output/point.rb, line 28 def y @position[1] end