class CTioga2::Graphics::Types::PointBasedBox
A box defined by an AlignedPoint
and two dimensions
Constants
- PointBasedBoxRE
A well formed point-based box must match the following regular expression.
Attributes
height[RW]
The height
point[RW]
The aligned point of the box:
width[RW]
The width
Public Class Methods
from_text(text, default = :frame)
click to toggle source
Returns a new PointBasedBox
object based on the text specification, which reads:
aligned_point:w(,h)
The default holds for point and dimensions
# File lib/ctioga2/graphics/types/boxes.rb, line 170 def self.from_text(text, default = :frame) if text =~ PointBasedBoxRE po,w,h = $1,$2,$3 point = AlignedPoint.from_text(po, default) width = Dimension.from_text(w, :x, default) if h height = Dimension.from_text(h, :y, default) else height = width.dup end return PointBasedBox.new(point, width, height) else raise "#{text} is not a point-based box." end end
new(point, width, height)
click to toggle source
Creates a new PointBasedBox
at the given point, with the given width and height.
# File lib/ctioga2/graphics/types/boxes.rb, line 154 def initialize(point, width, height) @point = point @width = width @height = height end
Public Instance Methods
to_frame_coordinates(t)
click to toggle source
Returns the frame coordinates of the box.
# File lib/ctioga2/graphics/types/boxes.rb, line 187 def to_frame_coordinates(t) dx = @width.to_figure(t, :x) dy = @height.to_figure(t, :y) a = @point.to_frame_coordinates(t, dx, dy) return @point.to_frame_coordinates(t, dx, dy) end