123456789_123456789_123456789_123456789_123456789_

Class: Layout::Path

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Entity
Instance Chain:
self, Entity
Inherits: Layout::Entity

Overview

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

Version:

  • LayOut 2018

Constant Summary

Class Method Summary

Instance Attribute Summary

Entity - Inherited

#locked=

The #locked= method sets the Entity as locked or unlocked.

#locked?

The #locked? method returns whether the Entity is locked or unlocked.

#on_shared_layer?

The #on_shared_layer? method returns whether or not the Entity is on a shared Layer.

#style

The #style method returns the Style of the Entity.

#style=

The #style= method sets the Style of the Entity.

#untransformed_bounds

The #untransformed_bounds method returns the untransformed bounds of the Entity.

#untransformed_bounds=

The #untransformed_bounds= method sets the untransformed bounds of the Entity.

Instance Method Summary

Entity - Inherited

#==

The #== method checks to see if the two Entitys are equal.

#bounds

The #bounds method returns the 2D rectangular bounds of the Entity.

#document

The #document method returns the Document that the Entity belongs to, or nil if it is not in a Document.

#drawing_bounds

The #drawing_bounds method returns the 2D rectangular drawing bounds of the Entity.

#group

The #group method returns the Group the Entity belongs to, or nil if it is not in a Group.

#layer_instance

The #layer_instance method returns the LayerInstance that the Entity is on, or nil if it is not associated with a LayerInstance.

#move_to_group

The #move_to_group method moves the Entity into a Group.

#move_to_layer

The #move_to_layer method moves the Entity to the given Layer.

#page

The #page method returns the Page that the Entity belongs to, or nil if it is on a shared Layer or not in a Document.

#transform!

The #transform! method transforms the Entity with a given ::Geom::Transformation2d.

#transformation

The #transformation method returns the explicit ::Geom::Transformation2d.

Constructor Details

.new(start_point, end_point) ⇒ Path .new(start_point, control_point_1, control_point_2, end_point) ⇒ Path .new(rectangle) ⇒ Path .new(ellipse) ⇒ Path

The #initialize method creates a new 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:

  • .new(start_point, end_point) ⇒ Path

    Parameters:

    Raises:

    • (ArgumentError)

      if the length between start point and end point is zero

  • .new(start_point, control_point_1, control_point_2, end_point) ⇒ Path

    Parameters:

    Raises:

    • (ArgumentError)

      if the length between start point and end point is zero

  • .new(rectangle) ⇒ Path

    Parameters:

    Raises:

    • (TypeError)

      if rectangle is not a Rectangle

  • .new(ellipse) ⇒ Path

    Parameters:

    Raises:

    • (TypeError)

      if ellipse is not an Ellipse

Version:

  • LayOut 2018

Class Method Details

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

The .new_arc method creates a new arc-shaped 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:

  • (Path)

    an arc path

Raises:

  • (ArgumentError)

    if radius is less than or equal to zero

  • (ArgumentError)

    if start angle is equal to end angle

Version:

  • LayOut 2018

Instance Attribute Details

#closed?Boolean (readonly)

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

Examples:

is_closed = path.closed?

Version:

  • LayOut 2018

Instance Method Details

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

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

Examples:

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

Overloads:

  • #append_point(point) ⇒ Path

    Parameters:

  • #append_point(control_point1, control_point2, point) ⇒ Path

    Parameters:

Raises:

Version:

  • LayOut 2018

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

The #arc method returns the parameters of an arc from the 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 Path, or nil if path is not a circle.

Examples:

center_point, radius = path.circle

Returns:

Version:

  • LayOut 2018

#close

The #close method closes the Path.

Examples:

path.close

Raises:

  • (LockedLayerError)

    if the Path is on a locked Layer

  • (ArgumentError)

    if the Path can not be closed becauase it contains less than three points.

  • (LockedEntityError)

    if the Path is locked

Version:

  • LayOut 2018

#end_arrowPath?

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

Examples:

path = Layout::Path.end_arrow(path_with_end_arrow)

Returns:

  • (Path, nil)

    The end arrow

Version:

  • LayOut 2018

#end_pointGeom::Point2d

The #end_point method returns the end point of the 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

Version:

  • LayOut 2018

#parametric_lengthFloat

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

Examples:

length = path.parametric_length

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)

Raises:

  • (ArgumentError)

    if the parametric value is less than zero or greater than the 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 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 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

Version:

  • LayOut 2018

#start_arrowPath?

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

Examples:

start_arrow = path.start_arrow

Returns:

  • (Path, nil)

    The start arrow

Version:

  • LayOut 2018

#start_pointGeom::Point2d

The #start_point method returns the start point of the 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

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)

Raises:

  • (ArgumentError)

    if the parametric value is less than zero or greater than the Path‘s parametric length

Version:

  • LayOut 2018

#windingInteger

The #winding method returns the winding type of the 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

Version:

  • LayOut 2019