Class
GSPath
A graphical path made of nodes.
Declaration
class GSPathDeclaration
@interface GSPath : GSShapeDeclaration
class GSPath(GSShape)Overview
A path describes one continuous outline contour; it is not divided into separate subpaths.
The nodes are stored in drawing order. On-curve nodes lie on the contour and define segment endpoints. Off-curve nodes control the shape of curve segments.
A segment runs from one on-curve node to the next on-curve node. The on-curve node type describes the segment ending at that node. A path time identifies a position within a segment by combining the ending on-curve node integer index with a fractional segment position.
Closed paths connect the final node to the first node. Open paths do not wrap at their ends. Navigation path APIs wrap indices for closed paths and reject out-of-range indices for open paths.
A path is expected to contain nodes during normal use. Empty paths can exist immediately after creation, but many path operations assume a populated path. Paths without on-curve nodes are interpreted as using quadratic path segments with implicit on-curve nodes.
Topics
Creating a Path
Creates a path from a Glyphs file dictionary representation.
Creates a path from the Glyphs file representation at the current parser position.
Creates a path from a sequence of node element strings.
Creates a closed rectangular path enclosing the rectangle.
Creates a closed cubic path approximating an ellipse inside the rectangle.
Creates a closed cubic path approximating a circle.
Creates a closed cubic path approximating an ellipse.
Closed/Open
Whether the final node connects to the first node.
Opens or closes the path and adjusts its endpoint nodes.
Opens or closes the path and adjusts its endpoint nodes.
Path Direction
The traversal direction of a path.
The direction in which the nodes traverse the path.
Reverses the path direction.
Reverses the path direction without registering undo or notifying the layer.
Nodes
An on-curve or off-curve point of a path.
The ordered nodes describing the path.
Replaces all nodes without registering undo or notifying the layer.
The number of nodes.
Inserting Nodes
Appends a node and aligns its position to the layer grid.
Appends a node without registering undo, aligning its position, or notifying the layer.
Appends nodes.
Appends a new node and aligns its position to the layer grid.
Appends a new node without registering undo, aligning its position, or notifying the layer.
Appends a cubic curve segment and aligns its node positions to the layer grid.
Appends a cubic curve segment without registering undo, aligning its node positions, or notifying the layer.
Inserts a node at an index and aligns its position to the layer grid.
Inserts an on-curve node at a path time while preserving the path shape.
Inserts an off-curve node into a quadratic segment.
Adds nodes at extrema of cubic curve segments.
Adds nodes at inflection points of cubic curve segments.
Removing Nodes
Removes nodes.
Removes the node at an index.
Removes a node.
Removes a node without registering undo, updating the layer selection, or notifying the layer.
Removes a node and adjusts adjacent nodes to keep the path structurally valid.
Removes a node and adjusts adjacent segments to approximate the path shape.
Removes a node and adjusts adjacent segments to approximate the path shape.
Node Navigation
The node at an index.
The index of a node, or
nilwhen the node is not in the path.An index from which every segment can be traversed in node order.
The next on-curve node after an index.
The previous on-curve node before an index.
For open paths, returns the first node of the path, otherwise
nil.For open paths, returns the last node of the path, otherwise
nil.The node used to begin traversing a closed path, or
nilfor an open path.The lowest on-curve node, preferring the leftmost node at equal height.
Moves trailing off-curve nodes to the beginning of a closed path.
Makes a node the start node of the path.
The index preceding the first on-curve node for TrueType path traversal.
Path Time
The point at a path time, or
nilwhen the path time does not identify a position on the path.Finds the point on the path nearest a point.
Returns the on-curve node nearest a path time.
Editing Nodes
Aligns a node opposite a point about a center point while preserving its distance from the center point.
Aligns a node opposite another node about a center node while preserving its distance from the center node.
Moves an off-curve node to the reflection of a point about a center point.
Normalizes node types and connections based on adjacent nodes.
Sets a node connection based on the alignment of adjacent nodes.
Moves an off-curve node by an offset while preserving its locked direction.
Moves an off-curve node by an offset, constrained using a corresponding node in another path.
Segments
The path represented as path segments.
The path represented as path segments without collecting path object information.
The segment associated with a node index.
The segment associated with a node index and the node index range it covers.
Geometry
The bounds of the path.
The bounds of the path nodes.
The unsigned area enclosed by the path.
The length of all path segments.
Whether the path encloses another path.
Intersections between the path and a line segment.
Tangents
The tangent angle at a node, or
nilwhen no tangent can be determined.The tangent angle at a node index, or
nilwhen no tangent can be determined.The tangent unit vector at a node index, or
nilwhen no tangent can be determined.The tangent unit vector at a node index, or
nilwhen no tangent can be determined.
Convenience
Replaces a node range with a sharp corner fitted to the neighboring segments.
Opens an on-curve corner by the offset distance.
Removes an off-curve node range from a quadratic segment.
Representations
An AppKit drawing path for the path.
Stroke outlines built from the path stroke attributes.
A path with path components expanded into outline nodes.
Removes outside overlaps at sharp line corners.
Replaces a corner, cap, segment, brush, or head hint with outline geometry.
A cubic path representation with special curve types converted to Bezier curves.
A path tracing the same outline using primitive node types and connections.
Paths tracing the same outline using primitive node types and connections.
Whether the path already uses primitive node types and connections.
Cleanup
Removes redundant nodes and rounds node positions to the layer grid.
Removes redundant nodes and rounds node positions to a grid.
Node indices that cleanup would keep.
Removes adjacent on-curve nodes at the same position.
Curve Conversion
The default tolerance for converting cubic curve segments to quadratic curve segments.
Converts the path to cubic curve segments.
The tolerance used when converting the path to quadratic curve segments.
Converts the path to quadratic curve segments.
Converts special curve node types to Bezier curve segments.
Converts the path to Hobby curve segments.
Applies converted quadratic segments to existing nodes.
Checking Path Contents
Whether the path contains at least one on-curve node.
Whether the path uses TrueType-compatible node types.
Whether the path contains quadratic curve node types.
Whether the path contains curve node types that are not cubic.
Whether any node contains pen point data.
Layer API
Notifies the path that one of its elements changed.
Encoding
Writes a Glyphs file representation.
Equality and Comparison
Whether another path has the same closed state, node count, and node positions.
A geometric hash for matching paths with the same node structure.
Enumerates matching node positions for a geometric hash.
A transform that maps a geometric hash to the matching position on the path.
Instance Methods
same as
checkConnectionsbut without notifying and undo. Good when loading the pathThe position at a node index, or
nilwhen the index does not match a node.same as ``setClosed:``` but without notifying and undo. Good when loading the path
Topics
Creating a Path
Creates a path from a Glyphs file dictionary representation.
Creates a path from the Glyphs file representation at the current parser position.
Creates a path from a sequence of node element strings.
Creates a closed rectangular path enclosing the rectangle.
Creates a closed cubic path approximating an ellipse inside the rectangle.
Creates a closed cubic path approximating a circle.
Creates a closed cubic path approximating an ellipse.
Closed/Open
Whether the final node connects to the first node.
Opens or closes the path and adjusts its endpoint nodes.
Opens or closes the path and adjusts its endpoint nodes.
Path Direction
The traversal direction of a path.
The direction in which the nodes traverse the path.
Reverses the path direction.
Reverses the path direction without registering undo or notifying the layer.
Nodes
An on-curve or off-curve point of a path.
The ordered nodes describing the path.
Replaces all nodes without registering undo or notifying the layer.
The number of nodes.
Inserting Nodes
Appends a node and aligns its position to the layer grid.
Appends a node without registering undo, aligning its position, or notifying the layer.
Appends nodes.
Appends a new node and aligns its position to the layer grid.
Appends a new node without registering undo, aligning its position, or notifying the layer.
Appends a cubic curve segment and aligns its node positions to the layer grid.
Appends a cubic curve segment without registering undo, aligning its node positions, or notifying the layer.
Inserts a node at an index and aligns its position to the layer grid.
Inserts an on-curve node at a path time while preserving the path shape.
Inserts an off-curve node into a quadratic segment.
Adds nodes at extrema of cubic curve segments.
Adds nodes at inflection points of cubic curve segments.
Removing Nodes
Removes nodes.
Removes the node at an index.
Removes a node.
Removes a node without registering undo, updating the layer selection, or notifying the layer.
Removes a node and adjusts adjacent nodes to keep the path structurally valid.
Removes a node and adjusts adjacent segments to approximate the path shape.
Removes a node and adjusts adjacent segments to approximate the path shape.
Node Navigation
The node at an index.
The index of a node, or
NSNotFoundwhen the node is not in the path.An index from which every segment can be traversed in node order.
The next on-curve node after an index.
The previous on-curve node before an index.
For open paths, returns the first node of the path, otherwise
nil.For open paths, returns the last node of the path, otherwise
nil.The node used to begin traversing a closed path, or
nilfor an open path.The lowest on-curve node, preferring the leftmost node at equal height.
Moves trailing off-curve nodes to the beginning of a closed path.
Makes a node the start node of the path.
The index preceding the first on-curve node for TrueType path traversal.
Path Time
The point at a path time.
Finds the point on the path nearest a point.
Returns the on-curve node nearest a path time.
Editing Nodes
Aligns a node opposite a point about a center point while preserving its distance from the center point.
Aligns a node opposite another node about a center node while preserving its distance from the center node.
Moves an off-curve node to the reflection of a point about a center point.
Normalizes node types and connections based on adjacent nodes.
Sets a node connection based on the alignment of adjacent nodes.
Moves an off-curve node by an offset while preserving its locked direction.
Moves an off-curve node by an offset, constrained using a corresponding node in another path.
Segments
The path represented as path segments.
The path represented as path segments without collecting path object information.
The segment associated with a node index.
The segment associated with a node index and the node index range it covers.
Geometry
The bounds of the path.
The bounds of the path nodes.
The unsigned area enclosed by the path.
The length of all path segments.
Whether the path encloses another path.
Intersections between the path and a line segment.
Tangents
The tangent angle at a node.
The tangent angle at a node index.
The tangent unit vector at a node index.
The tangent unit vector at a node index.
Convenience
Position for a node index.
Replaces a node range with a sharp corner fitted to the neighboring segments.
Opens an on-curve corner by the offset distance.
Removes an off-curve node range from a quadratic segment.
Representations
An AppKit drawing path for the path.
Stroke outlines built from the path stroke attributes.
A path with path components expanded into outline nodes.
Removes outside overlaps at sharp line corners.
Replaces a corner, cap, segment, brush, or head hint with outline geometry.
A cubic path representation with special curve types converted to Bezier curves.
A path tracing the same outline using primitive node types and connections.
Paths tracing the same outline using primitive node types and connections.
Whether the path already uses primitive node types and connections.
Cleanup
Removes redundant nodes and rounds node positions to the layer grid.
Removes redundant nodes and rounds node positions to a grid.
Adds the node indices that cleanup would keep.
Removes adjacent on-curve nodes at the same position.
Curve Conversion
The default tolerance for converting cubic curve segments to quadratic curve segments.
Converts the path to cubic curve segments.
The tolerance used when converting the path to quadratic curve segments.
Converts the path to quadratic curve segments.
Converts the path to quadratic curve segments.
Converts special curve node types to Bezier curve segments.
Converts the path to Hobby curve segments.
Applies converted quadratic segments to existing nodes.
Checking Path Contents
Whether the path contains at least one on-curve node.
Whether the path uses TrueType-compatible node types.
Whether the path contains quadratic curve node types.
Whether the path contains curve node types that are not cubic.
Whether any node contains pen point data.
Layer API
Notifies the path that one of its elements changed.
Encoding
Writes a Glyphs file representation.
Equality and Comparison
Whether another path has the same closed state, node count, and node positions.
A geometric hash for matching paths with the same node structure.
Enumerates matching node positions for a geometric hash.
A transform that maps a geometric hash to the matching position on the path.
Instance Methods
same as
checkConnectionsbut without notifying and undo. Good when loading the pathsame as ``setClosed:``` but without notifying and undo. Good when loading the path
Relationships
Inherits From
Conforms To
Foundation.NSCopying- GSContainerProtocol
- GSDrawPath
- GSSelectableElementProtocol
- GSUserDataProtocol
ObjectiveC.NSObjectProtocolSwift.CVarArgSwift.CustomDebugStringConvertibleSwift.CustomStringConvertibleSwift.EquatableSwift.Hashable
Relationships
Inherits From
Conforms To
See Also
Shapes
An abstract base class for graphical elements stored in a glyph layer.
A reference to another glyph placed as a shape in a glyph layer.
A shape group combines zero or more shapes into a single shape, forming a shape tree.