# `GSNode`

*Class*

An on-curve or off-curve point of a path.

## Declaration

```swift
class GSNode
```

```objc
@interface GSNode : NSObject
```

```python
class GSNode(NSObject)
```

## Overview

Nodes form the ordered sequence that describes a path. There is a single off-curve node type and multiple different on-curve node types. An on-curve node lies on the path, and its type describes the path segment ending at that node. An off-curve node, also known as a handle, controls the curvature of a path segment and does not necessarily lie on the path.

For every on-curve node, a incoming path segment ends and an outgoing path segment begins. The node connection describes the relationship between these two segments.

A node can exist without a parent path, in which case its layer and glyph are also unavailable.

Use path APIs to add or remove nodes so that the node and path remain consistent. Regular mutation APIs register undo and notify the path when applicable. Fast APIs omit this behavior and require the caller to manage related changes.

Conceptually, `GSNode` is a [`GSElement`](/Core/GlyphsCore/GSElement), but it does not inherit from `GSElement` for optimizations reasons.

## Topics

### Creating a Node

- [`GSNode initWithPosition:type:connection:`](/Core/GlyphsCore/GSNode/initWithPosition:type:connection:) — Creates a node.
- [`GSNode initWithArray:format:`](/Core/GlyphsCore/GSNode/initWithArray:format:) — Creates a node from a Glyphs file array representation.
- [`GSNode initWithDict:format:`](/Core/GlyphsCore/GSNode/initWithDict:format:) — Creates a node from a Glyphs file dictionary representation.
- [`GSNode initWithElementString:`](/Core/GlyphsCore/GSNode/initWithElementString:) — Creates a node from a Glyphs file element string representation.
- [`GSNode initWithGlyphsParser:format:`](/Core/GlyphsCore/GSNode/initWithGlyphsParser:format:) — Creates a node from the Glyphs file representation at the current parser position.

### Type

- [`GSNode.GSNodeType`](/Core/GlyphsCore/GSNode/GSNodeType) — The type of path segment that the node describes.
- [`GSNode.type`](/Core/GlyphsCore/GSNode/type) — The type of the node.
- [`GSNode.typeFast`](/Core/GlyphsCore/GSNode/typeFast) — More efficient access to the node type.
- [`GSNode.typeTag`](/Core/GlyphsCore/GSNode/typeTag) — A character representing the type of the node.

### Connection

- [`GSNode.GSNodeConnection`](/Core/GlyphsCore/GSNode/GSNodeConnection) — The transition of a path through an on-curve node.
- [`GSNode.connection`](/Core/GlyphsCore/GSNode/connection) — The connection between the incoming and outgoing path segments.
- [`GSNode.isSmooth`](/Core/GlyphsCore/GSNode/isSmooth) — Convenience to simplify checking the connection.
- [`GSNode checkConnection`](/Core/GlyphsCore/GSNode/checkConnection) — Automatically sets the connection for the node depending on the angle of the incoming and outgoing path segments.
- [`GSNode toggleConnection:`](/Core/GlyphsCore/GSNode/toggleConnection:) — Toggles the connection type between [`GSNodeConnection.GSNodeConnectionSharp`](/Core/GlyphsCore/GSNode/GSNodeConnection/GSNodeConnectionSharp) and [`GSNodeConnection.GSNodeConnectionSmooth`](/Core/GlyphsCore/GSNode/GSNodeConnection/GSNodeConnectionSmooth).
- [`GSNode toggleConnection:superSmooth:`](/Core/GlyphsCore/GSNode/toggleConnection:superSmooth:) — Toggles the connection type between [`GSNodeConnection.GSNodeConnectionSharp`](/Core/GlyphsCore/GSNode/GSNodeConnection/GSNodeConnectionSharp) and [`GSNodeConnection.GSNodeConnectionSmooth`](/Core/GlyphsCore/GSNode/GSNodeConnection/GSNodeConnectionSmooth)/[`GSNodeConnection.GSNodeConnectionSuperSmooth`](/Core/GlyphsCore/GSNode/GSNodeConnection/GSNodeConnectionSuperSmooth).

### Orientation

- [`GSElementOrientation`](/Core/GlyphsCore/GSElementOrientation) — The orientation for coordinate values.
- [`GSNode.orientation`](/Core/GlyphsCore/GSNode/orientation) — The orientation of the node position.

### Position

- [`GSNode.position`](/Core/GlyphsCore/GSNode/position) — The position in layer coordinates.
- [`GSNode positionForLayerWidth:`](/Core/GlyphsCore/GSNode/positionForLayerWidth:) — The position in layer coordinates for a layer width.
- [`GSNode setPosition:forLayerWidth:`](/Core/GlyphsCore/GSNode/setPosition:forLayerWidth:) — Sets the position in layer coordinates for a layer width.
- [`GSNode.positionFast`](/Core/GlyphsCore/GSNode/positionFast) — The position without orientation adjustment.
- [`GSNode setPositionFast:`](/Core/GlyphsCore/GSNode/setPositionFast:) — Sets the position without registering undo or notifying the path.
- [`GSNode setPositionFast:grid:`](/Core/GlyphsCore/GSNode/setPositionFast:grid:) — Sets the unrounded position and rounds the position to a grid without registering undo or notifying the path.
- [`GSNode.positionPrecise`](/Core/GlyphsCore/GSNode/positionPrecise) — The unrounded position in layer coordinates.
- [`GSNode positionPreciseForLayerWidth:`](/Core/GlyphsCore/GSNode/positionPreciseForLayerWidth:) — The unrounded position in layer coordinates for a layer width.
- [`GSNode positionPreciseFast`](/Core/GlyphsCore/GSNode/positionPreciseFast) — The unrounded position without orientation adjustment.
- [`GSNode roundToGrid:`](/Core/GlyphsCore/GSNode/roundToGrid:) — Rounds the position to a grid.
- [`GSNode roundToGridFast:`](/Core/GlyphsCore/GSNode/roundToGridFast:) — Rounds the position to a grid without registering undo or notifying the path.

### Locking

- [`GSNode.locked`](/Core/GlyphsCore/GSNode/locked) — Whether the node should reject edits.

### Path Navigation

- [`GSNode nodeIndex`](/Core/GlyphsCore/GSNode/nodeIndex) — The index of the node in its path.
- [`GSNode nextOncurveNode`](/Core/GlyphsCore/GSNode/nextOncurveNode) — The next on-curve node in the path.
- [`GSNode previousOncurveNode`](/Core/GlyphsCore/GSNode/previousOncurveNode) — The previous on-curve node in the path.

### Path API

- [`GSNode makeNodeFirst`](/Core/GlyphsCore/GSNode/makeNodeFirst) — Makes the node the start node of its path.
- [`GSNode elementDidChange:`](/Core/GlyphsCore/GSNode/elementDidChange:) — Notifies the path that the node changed.

### Attachments

- [`GSNode canAttachCorner`](/Core/GlyphsCore/GSNode/canAttachCorner) — Whether a corner component can be attached to the node.
- [`GSNode penPoint`](/Core/GlyphsCore/GSNode/penPoint) — The pen point at the node, or `nil` if none exists.

### Owners

- [`GSNode.parent`](/Core/GlyphsCore/GSNode/parent) — The path containing the node, or `nil` when the node is not part of a path.
- [`GSNode.layer`](/Core/GlyphsCore/GSNode/layer) — The layer containing the node, or `nil` when the node is not part of a layer.
- [`GSNode.glyph`](/Core/GlyphsCore/GSNode/glyph) — The glyph containing the node, or `nil` when the node is not part of a glyph.

### Attributes

- [`GSNode.attributes`](/Core/GlyphsCore/GSNode/attributes) — Additional values associated with the node.
- [`GSNode.countOfAttributes`](/Core/GlyphsCore/GSNode/countOfAttributes) — The number of attributes.
- [`GSNode attributeForKey:`](/Core/GlyphsCore/GSNode/attributeForKey:) — The value for an attribute key, or `nil` if no value is set.
- [`GSNode setAttribute:forKey:`](/Core/GlyphsCore/GSNode/setAttribute:forKey:) — Sets or removes an attribute.
- [`GSNode setAttributes:format:`](/Core/GlyphsCore/GSNode/setAttributes:format:) — Replaces all attributes using values encoded for a file format version.
- [`GSNode setAttributesFast:format:`](/Core/GlyphsCore/GSNode/setAttributesFast:format:) — Replaces all attributes without registering undo or notifying the path.
- [`GSNode removeAttributeForKey:`](/Core/GlyphsCore/GSNode/removeAttributeForKey:) — Removes an attribute.

### Metadata

- [`GSNode.name`](/Core/GlyphsCore/GSNode/name) — A user-assigned name of the node.
- [`GSNode.hoiInfo`](/Core/GlyphsCore/GSNode/hoiInfo) — Higher-order interpolation definitions where the keys are axis tags.
- [`GSNode.hobbyInfo`](/Core/GlyphsCore/GSNode/hobbyInfo) — Hobby node information associated with the node.
- [`GSNode penPoint`](/Core/GlyphsCore/GSNode/penPoint) — The pen point at the node, or `nil` if none exists.
- [`GSNode.associatedPenPoints`](/Core/GlyphsCore/GSNode/associatedPenPoints) — The pen points associated with the node.

### Temporary Data

- [`GSNode.tempData`](/Core/GlyphsCore/GSNode/tempData) — Values associated with the node for transient use.
- [`GSNode.countOfTempData`](/Core/GlyphsCore/GSNode/countOfTempData) — The number of temporary values.
- [`GSNode tempDataForKey:`](/Core/GlyphsCore/GSNode/tempDataForKey:) — The temporary value for a key, or `nil` if no value is set.
- [`GSNode setTempData:forKey:`](/Core/GlyphsCore/GSNode/setTempData:forKey:) — Sets or removes a temporary value.

### Encoding

- [`GSNode propertyListValueFormat:error:`](/Core/GlyphsCore/GSNode/propertyListValueFormat:error:) — Returns a Property List representation of the node.
- [`GSNode elementString`](/Core/GlyphsCore/GSNode/elementString) — Returns an element string representation of the node.

### Undo

- [`GSNode.undoManager`](/Core/GlyphsCore/GSNode/undoManager) — Returns the undo manager of the containing glyph.
- [`GSNode.undoManagerCheck`](/Core/GlyphsCore/GSNode/undoManagerCheck) — Returns the undo manager of the containing glyph, if undo is enabled for the glyph.

### Equality

- [`GSNode isEqualToNode:`](/Core/GlyphsCore/GSNode/isEqualToNode:) — Checks if the node is equal to another node.

## Relationships

### Inherits From

- `NSObject`

### Conforms To

- [`GSSelectableElementProtocol`](/Core/GlyphsCore/GSSelectableElementProtocol)
- [`GSUserDataProtocol`](/Core/GlyphsCore/GSUserDataProtocol)
- `NSCoding`
- `NSCopying`

## See Also

### Nodes

- [`GSPath.nodes`](/Core/GlyphsCore/GSPath/nodes) — The ordered nodes describing the path.
- [`GSPath setNodesFast:`](/Core/GlyphsCore/GSPath/setNodesFast:) — Replaces all nodes without registering undo or notifying the layer.
- [`GSPath countOfNodes`](/Core/GlyphsCore/GSPath/countOfNodes) — The number of nodes.

