Class: Layout::Path

Inherits:
Entity show all

Overview

A path entity represents a continuous, multi-segment polyline or bezier curve.

Version:

  • LayOut 2018

Constant Summary #

Layout::Path::POINT_TYPE_MOVE_TO
Layout::Path::POINT_TYPE_LINE_TO
Layout::Path::POINT_TYPE_BEZIER_TO
Layout::Path::POINT_TYPE_ARC_CENTER
Layout::Path::POINT_TYPE_BEZIER_CONTROL
Layout::Path::POINT_TYPE_CLOSE
Layout::Path::PATH_WINDING_NONE
Layout::Path::PATH_WINDING_CLOCKWISE
Layout::Path::PATH_WINDING_COUNTER_CLOCKWISE

Class Method Summary # collapse

Instance Method Summary # collapse

Methods inherited from Entity

#==, #bounds, #document, #drawing_bounds, #group, #layer_instance, #locked=, #locked?, #move_to_group, #move_to_layer, #on_shared_layer?, #page, #style, #style=, #transform!, #transformation, #untransformed_bounds, #untransformed_bounds=

Constructor Details

#initialize(start_point, end_point) ⇒ Layout::Path #initialize(start_point, control_point_1, control_point_2, end_point) ⇒ Layout::Path #initialize(rectangle) ⇒ Layout::Path #initialize(ellipse) ⇒ Layout::Path

The #initialize method creates a new Layout::Path between a start point and an end point, or from a provided Rectangle or Ellipse.

Examples:

start = Geom::Point2d.new(1, 1)
end = Geom::Point2d.new(2, 2)
new_path = Layout::Path.new(start, end)
start = Geom::Point2d.new(1, 1)
control_1 = Geom::Point2d.new(1.5, 1)
control_2 = Geom::Point2d.new(1, 1.5)
end = Geom::Point2d.new(2, 2)
new_path = Layout::Path.new(start, control_1, control_2, end)

Overloads:

  • #initialize(start_point, end_point) ⇒ Layout::Path

    Returns a straight path.

    Parameters:

    Raises:

    • (ArgumentError)

      if the length between start point and end point is zero

  • #initialize(start_point, control_point_1, control_point_2, end_point) ⇒ Layout::Path

    Returns a bezier path.

    Parameters:

    Raises:

    • (ArgumentError)

      if the length between start point and end point is zero

  • #initialize(rectangle) ⇒ Layout::Path

    Returns a path created from the Rectangle.

    Parameters:

    Raises:

    • (TypeError)

      if rectangle is not a Rectangle

  • #initialize(ellipse) ⇒ Layout::Path

    Returns a path created from the Ellipse.

    Parameters:

    Raises:

    • (TypeError)

      if ellipse is not an Ellipse

Version:

  • LayOut 2018

Class Method Details

.new_arc(center_point, radius, start_angle, end_angle) ⇒ Layout::Path

The new_arc method creates a new arc-shaped Layout::Path.

Examples:

center = Geom::Point2d.new(5, 5)
radius = 2.0
start_angle = 180.0
end_angle = 360.0
arc = Layout::Path.new_arc(center, radius, start_angle, end_angle)

Parameters:

  • center_point (Geom::Point2d)
  • radius (Float)
  • start_angle (Float)
  • end_angle (Float)

Returns:

Raises:

  • (ArgumentError)

    if radius is less than or equal to zero

  • (ArgumentError)

    if start angle is equal to end angle

Version:

  • LayOut 2018

Instance Method Details

#append_point(point) ⇒ Layout::Path #append_point(control_point1, control_point2, point) ⇒ Layout::Path

The #append_point method appends a Geom::Point2d to the end of the Layout::Path.

Examples:

point = Geom::Point2d.new(2, 5)
path.append_point(point)

Overloads:

Raises:

Version:

  • LayOut 2018

#arcArray(Geom::Point2d, Float, Float, Float)?

The #arc method returns the parameters of an arc from the Layout::Path, or nil if path is not an arc.

Examples:

start_angle, radius, start, end = path.arc

Returns:

  • (Array(Geom::Point2d, Float, Float, Float), nil)

    The center point, radius, start angle, and end angle

Version:

  • LayOut 2018

#circleArray(Geom::Point2d, Float)?

The #circle method returns the parameters of a circle from the Layout::Path, or nil if path is not a circle.

Examples:

center_point, radius = path.circle

Returns:

Version:

  • LayOut 2018

#closeObject

The #close method closes the Layout::Path.

Examples:

path.close

Raises:

Version:

  • LayOut 2018

#closed?Boolean

The #closed? method returns whether the Layout::Path is closed.

Examples:

is_closed = path.closed?

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#end_arrowLayout::Path?

The #end_arrow method creates a new Layout::Path from an end arrow.

Examples:

path = Layout::Path.end_arrow(path_with_end_arrow)

Returns:

Version:

  • LayOut 2018

#end_pointGeom::Point2d

The #end_point method returns the end point of the Layout::Path.

Examples:

start_point = Geom::Point2d.new(1, 1)
end_point = Geom::Point2d.new(2, 2)
path = Layout::Path.new(start_point, end_point)
# should be equal to end_point
endp = path.end_point

Returns:

Version:

  • LayOut 2018

#parametric_lengthFloat

The #parametric_length method returns the parametric length for the Layout::Path. The parametric length is the length with respect to the curve of the Layout::Path.

Examples:

length = path.parametric_length

Returns:

  • (Float)

Version:

  • LayOut 2018

#point_at(parametric_value) ⇒ Geom::Point2d

The #point_at method returns the Geom::Point2d at a given parametric value.

Examples:

length = path.parametric_length
# Get the point halfway along the path
halfway_point = path.point_at(length/2)

Parameters:

  • parametric_value (Float)

Returns:

Raises:

  • (ArgumentError)

    if the parametric value is less than zero or greater than the Layout::Path's parametric length

Version:

  • LayOut 2018

#point_typesArray<Integer>

The #point_types method returns an array of point types corresponding to the Geom::Point2ds in the Layout::Path.

A point type can be one of the following values:

POINT_TYPE_MOVE_TO
POINT_TYPE_LINE_TO
POINT_TYPE_BEZIER_TO
POINT_TYPE_ARC_CENTER
POINT_TYPE_BEZIER_CONTROL
POINT_TYPE_CLOSE

Examples:

types = path.point_types

Returns:

  • (Array<Integer>)

    An array of integers that correspond with point types.

Version:

  • LayOut 2018

#pointsArray<Geom::Point2d>

The #points method returns an array of Geom::Point2ds in the Layout::Path.

Examples:

start_point = Geom::Point2d.new(1, 1)
end_point = Geom::Point2d.new(2, 2)
new_path = Layout::Path.new(start_point, end_point)
# Should be an array with points [1, 1] and [2, 2]
points = new_path.points

Returns:

Version:

  • LayOut 2018

#start_arrowLayout::Path?

The #start_arrow method creates a new Layout::Path from a start arrow.

Examples:

start_arrow = path.start_arrow

Returns:

Version:

  • LayOut 2018

#start_pointGeom::Point2d

The #start_point method returns the start point of the Layout::Path.

Examples:

start_point = Geom::Point2d.new(1, 1)
end_point = Geom::Point2d.new(2, 2)
path = Layout::Path.new(start_point, end_point)
# should be equal to start_point
start = path.start_point

Returns:

Version:

  • LayOut 2018

#tangent_at(parametric_value) ⇒ Geom::Vector2d

The #tangent_at method returns the tangent Geom::Vector2d at the given parametric value.

Examples:

length = path.parametric_length
# Get the tangent halfway along the path
halfway_tangent = path.tangent_at(length/2)

Parameters:

  • parametric_value (Float)

Returns:

Raises:

  • (ArgumentError)

    if the parametric value is less than zero or greater than the Layout::Path's parametric length

Version:

  • LayOut 2018

#windingInteger

The #winding method returns the winding type of the Layout::Path.

A point type can be one of the following values:

PATH_WINDING_NONE
PATH_WINDING_CLOCKWISE
PATH_WINDING_COUNTER_CLOCKWISE

Examples:

winding = path.winding

Returns:

  • (Integer)

Version:

  • LayOut 2019