# GSLayer Shapes

*API Collection*

The paths and components that form the outline of a layer.

## Overview

Shapes can be addressed linearly using [`GSLayer.shapes`](/Core/GlyphsCore/GSLayer/shapes) or as a hierarchy using [`GSLayer.rootGroup`](/Core/GlyphsCore/GSLayer/rootGroup). The linear order is the storage order of all layer shapes, including shape groups. The hierarchy represents shape groups and their members in a tree structure.

## Topics

### Shapes

- [`GSLayer.shapes`](/Core/GlyphsCore/GSLayer/shapes) — An array of the shape objects defining the visual part of the layer.
- [`GSLayer setShapesFast:`](/Core/GlyphsCore/GSLayer/setShapesFast:) — Replaces the shapes without undo registration or KVO notifications.
- [`GSLayer setShapes:hints:`](/Core/GlyphsCore/GSLayer/setShapes:hints:) — Replaces the shapes and hints together.
- [`GSLayer getCopyOfContentFromLayer:doSelection:`](/Core/GlyphsCore/GSLayer/getCopyOfContentFromLayer:doSelection:) — Copies shapes, hints, anchors, and optionally selected nodes from another layer.
- [`GSLayer countOfShapes`](/Core/GlyphsCore/GSLayer/countOfShapes) — The number of shapes in the layer.
- [`GSLayer indexOfObjectInShapes:`](/Core/GlyphsCore/GSLayer/indexOfObjectInShapes:) — Returns the linear shape index of a shape.
- [`GSLayer objectInShapesAtIndex:`](/Core/GlyphsCore/GSLayer/objectInShapesAtIndex:) — Returns the shape at the given linear shape index.
- [`GSLayer objectInShapesAtIndexFast:`](/Core/GlyphsCore/GSLayer/objectInShapesAtIndexFast:) — Returns the shape at the given linear shape index without locking.
- [`GSLayer clear`](/Core/GlyphsCore/GSLayer/clear) — Removes shapes, anchors, hints, and selection from the layer.

### Shape Groups

- [`GSLayer.rootGroup`](/Core/GlyphsCore/GSLayer/rootGroup) — A shape group containing all shapes of the layer.
- [`GSLayer.shapeGroups`](/Core/GlyphsCore/GSLayer/shapeGroups) — The shape groups keyed by group identifier.
- [`GSLayer reconfigureShapeGroupsSkippingPreconditionCheck:`](/Core/GlyphsCore/GSLayer/reconfigureShapeGroupsSkippingPreconditionCheck:) — Reconfigures the shape groups (setting their member ranges) and reorders `shapes` to match.

### Adding Shapes

- [`GSLayer insertObject:inShapesAtIndex:`](/Core/GlyphsCore/GSLayer/insertObject:inShapesAtIndex:) — Inserts a shape at the given linear shape index.
- [`GSLayer addShape:`](/Core/GlyphsCore/GSLayer/addShape:) — Adds a shape at the top of the layer.
- [`GSLayer addShapeFast:`](/Core/GlyphsCore/GSLayer/addShapeFast:) — Adds a shape at the top of the layer without undo registration or KVO notifications.
- [`GSLayer addShapes:`](/Core/GlyphsCore/GSLayer/addShapes:) — Adds shapes at the top of the layer.
- [`GSLayer addShapesFast:`](/Core/GlyphsCore/GSLayer/addShapesFast:) — Adds shapes at the top of the layer without undo registration or KVO notifications.

### Removing and Replacing Shapes

- [`GSLayer removeShape:`](/Core/GlyphsCore/GSLayer/removeShape:) — Removes a shape from the layer.
- [`GSLayer removeShapes:`](/Core/GlyphsCore/GSLayer/removeShapes:) — Removes shapes from the layer.
- [`GSLayer removeShapesAtIndexes:`](/Core/GlyphsCore/GSLayer/removeShapesAtIndexes:) — Removes the shapes at the given linear shape indexes.
- [`GSLayer removeObjectFromShapesAtIndex:`](/Core/GlyphsCore/GSLayer/removeObjectFromShapesAtIndex:) — Removes the shape at the given linear shape index.
- [`GSLayer replaceShapeAtIndex:withShape:`](/Core/GlyphsCore/GSLayer/replaceShapeAtIndex:withShape:) — Replaces the shape at the given linear shape index.

### Moving Shapes in Groups

- [`GSLayer handleShapesFromShapes:`](/Core/GlyphsCore/GSLayer/handleShapesFromShapes:) — Returns `subjects` reordered such that the relative order is the same as in `shapes`, excluding any shapes in `subjects` that are members of a shape group in `subjects`.
- [`GSLayer moveShapes:copyBuffer:intoGroup:childIndex:`](/Core/GlyphsCore/GSLayer/moveShapes:copyBuffer:intoGroup:childIndex:) — Moves or copies the given shapes to a new location in the layer’s shape group tree.
- [`GSLayer createShapeGroupFromShapes:`](/Core/GlyphsCore/GSLayer/createShapeGroupFromShapes:) — Combines the given shapes into a new shape group.
- [`GSLayer dissolveShapeGroup:`](/Core/GlyphsCore/GSLayer/dissolveShapeGroup:) — Dissolves the given shape group by replacing it with its direct members.

### Shape Enumeration

- [`GSLayer enumerateShapesUsingBlock:`](/Core/GlyphsCore/GSLayer/enumerateShapesUsingBlock:) — Invokes the block for all shapes in linear shape order.
- [`GSLayer enumeratePathsUsingBlock:`](/Core/GlyphsCore/GSLayer/enumeratePathsUsingBlock:) — Invokes the block for all path shapes in linear shape order.
- [`GSLayer enumeratePathsWithOptions:usingBlock:`](/Core/GlyphsCore/GSLayer/enumeratePathsWithOptions:usingBlock:) — Invokes the block for all path shapes using the given enumeration options.
- [`GSLayer enumerateComponentsUsingBlock:`](/Core/GlyphsCore/GSLayer/enumerateComponentsUsingBlock:) — Invokes the block for all component shapes in linear shape order.
- [`GSLayer enumerateComponentsWithOptions:usingBlock:`](/Core/GlyphsCore/GSLayer/enumerateComponentsWithOptions:usingBlock:) — Invokes the block for all component shapes using the given enumeration options.

### Shape Proxies

- [`GSLayer.paths`](/Core/GlyphsCore/GSLayer/paths) — A proxy for iterating and accessing path shapes.
- [`GSLayer indexOfPath:`](/Core/GlyphsCore/GSLayer/indexOfPath:) — Returns the linear shape index of a path.
- [`GSLayer.components`](/Core/GlyphsCore/GSLayer/components) — A proxy for iterating and accessing component shapes.
- [`GSLayer.allComponents`](/Core/GlyphsCore/GSLayer/allComponents) — The component shapes in the layer.
- [`GSLayer.countOfPaths`](/Core/GlyphsCore/GSLayer/countOfPaths) — The number of path shapes in the layer.
- [`GSLayer.countOfComponents`](/Core/GlyphsCore/GSLayer/countOfComponents) — The number of component shapes in the layer.
- [`GSLayer.countOfImages`](/Core/GlyphsCore/GSLayer/countOfImages) — The number of image shapes in the layer.

### Nodes

- [`GSLayer.allNodes`](/Core/GlyphsCore/GSLayer/allNodes) — All nodes from all path shapes in linear shape order.
- [`GSLayer allNodesCount`](/Core/GlyphsCore/GSLayer/allNodesCount) — The number of nodes in all path shapes.
- [`GSLayer nodeAtIndexPath:`](/Core/GlyphsCore/GSLayer/nodeAtIndexPath:) — Returns the node at an index path.
- [`GSLayer indexPathOfNode:`](/Core/GlyphsCore/GSLayer/indexPathOfNode:) — Returns the index path of a node in this layer.
- [`GSLayer.selNode`](/Core/GlyphsCore/GSLayer/selNode) — The selected node when exactly one node is selected.
- [`GSLayer sortedSelectedNodes`](/Core/GlyphsCore/GSLayer/sortedSelectedNodes) — The selected nodes in path order.

### Node Hit Testing

- [`GSLayer nodeAtPoint:excludeNode:ignoreLocked:tolerance:`](/Core/GlyphsCore/GSLayer/nodeAtPoint:excludeNode:ignoreLocked:tolerance:) — Returns the nearest node to a point, excluding one node.
- [`GSLayer nodeAtPoint:excludeNodes:traverseComponents:ignoreLocked:tolerance:`](/Core/GlyphsCore/GSLayer/nodeAtPoint:excludeNodes:traverseComponents:ignoreLocked:tolerance:) — Returns the nearest node to a point, excluding a set of objects.
- [`GSLayer indexPathOfNodeAtX:actualPosition:`](/Core/GlyphsCore/GSLayer/indexPathOfNodeAtX:actualPosition:) — Returns the index path of an on-curve node near the given x position.
- [`GSLayer indexPathOfNodeAtY:actualPosition:`](/Core/GlyphsCore/GSLayer/indexPathOfNodeAtY:actualPosition:) — Returns the index path of an on-curve node near the given y position.

### Segments

- [`GSLayer segments`](/Core/GlyphsCore/GSLayer/segments) — The path segments from all path shapes in linear shape order.
- [`GSLayer segmentAtIndexPath:`](/Core/GlyphsCore/GSLayer/segmentAtIndexPath:) — Returns the segment at an index path.

### Component Names

- [`GSLayer.componentNames`](/Core/GlyphsCore/GSLayer/componentNames) — The component names of the direct component shapes.
- [`GSLayer.componentNamesTraversingComponents`](/Core/GlyphsCore/GSLayer/componentNamesTraversingComponents) — The component names of direct and nested component shapes.
- [`GSLayer componentNamesTraverseComponents:`](/Core/GlyphsCore/GSLayer/componentNamesTraverseComponents:) — Returns component names, optionally including nested component shapes.

### Component Construction

- [`GSLayer makeComponents`](/Core/GlyphsCore/GSLayer/makeComponents) — Builds component shapes from glyph information.
- [`GSLayer findComponent:baseName:withSuffix:`](/Core/GlyphsCore/GSLayer/findComponent:baseName:withSuffix:) — Finds a component glyph name for a base glyph and suffix context.

### Component Decomposition

- [`GSLayer copyDecomposedLayer`](/Core/GlyphsCore/GSLayer/copyDecomposedLayer) — A copy of the layer with components decomposed.
- [`GSLayer decomposeComponent:`](/Core/GlyphsCore/GSLayer/decomposeComponent:) — Decomposes one component.
- [`GSLayer decomposeComponentDontNotify:`](/Core/GlyphsCore/GSLayer/decomposeComponentDontNotify:) — Decomposes one component without triggering layer updates.
- [`GSLayer decomposeComponentDontNotify:callback:`](/Core/GlyphsCore/GSLayer/decomposeComponentDontNotify:callback:) — Decomposes one component without triggering layer updates and invokes a callback for decomposed component layers.
- [`GSLayer decomposeComponents`](/Core/GlyphsCore/GSLayer/decomposeComponents) — Decomposes all components.
- [`GSLayer decomposeComponentsCallback:`](/Core/GlyphsCore/GSLayer/decomposeComponentsCallback:) — Decomposes all components and invokes a callback for decomposed component layers.
- [`GSLayer decomposeCorners`](/Core/GlyphsCore/GSLayer/decomposeCorners) — Decomposes corner components.
- [`GSLayer decomposeSmartOutlines`](/Core/GlyphsCore/GSLayer/decomposeSmartOutlines) — Decomposes smart outline components.

### Component Export

- [`GSLayer prepareComponentsForTrueTypeExport:keepTransformed:`](/Core/GlyphsCore/GSLayer/prepareComponentsForTrueTypeExport:keepTransformed:) — Prepares components for TrueType export.

### Component Alignment

- [`GSLayer alignComponents`](/Core/GlyphsCore/GSLayer/alignComponents) — Aligns components according to their alignment settings.
- [`GSLayer alignComponents:`](/Core/GlyphsCore/GSLayer/alignComponents:) — Aligns components according to their alignment settings.
- [`GSLayer doAlignComponents`](/Core/GlyphsCore/GSLayer/doAlignComponents) — Performs component alignment immediately.
- [`GSLayer needsAlignment`](/Core/GlyphsCore/GSLayer/needsAlignment) — Whether component alignment needs to be updated.
- [`GSLayer getPositionsFromLayer:`](/Core/GlyphsCore/GSLayer/getPositionsFromLayer:) — Copies shape positions and related hint positions from another layer.

### Shape Locks

- [`GSLayer lockReadShapes`](/Core/GlyphsCore/GSLayer/lockReadShapes) — Acquires the read lock for shapes.
- [`GSLayer unlockReadShapes`](/Core/GlyphsCore/GSLayer/unlockReadShapes) — Releases the read lock for shapes.
- [`GSLayer lockWriteShapes`](/Core/GlyphsCore/GSLayer/lockWriteShapes) — Acquires the write lock for shapes.
- [`GSLayer unlockWriteShapes`](/Core/GlyphsCore/GSLayer/unlockWriteShapes) — Releases the write lock for shapes.

## See Also

- [GSLayer Kind](/Core/GlyphsCore/GSLayer-Kind) — The different roles that a layer can serve.
- [GSLayer Bounds](/Core/GlyphsCore/GSLayer-Bounds) — Bounding rectangles of outlines, selections, and metrics.
- [GSLayer Metrics](/Core/GlyphsCore/GSLayer-Metrics) — Side bearings, baseline offsets, layer box, and metrics keys.
- [GSLayer Grid](/Core/GlyphsCore/GSLayer-Grid) — Setting for rounding coordinates on a layer.
- [GSLayer Background](/Core/GlyphsCore/GSLayer-Background) — Background content and reference images associated with a layer.
- [GSLayer Anchors](/Core/GlyphsCore/GSLayer-Anchors) — Named attachment points on a layer.
- [GSLayer Hints](/Core/GlyphsCore/GSLayer-Hints) — Manual and generated hint data on a layer.
- [GSLayer Guides](/Core/GlyphsCore/GSLayer-Guides) — Layer-local guides used while editing outlines.
- [GSLayer Kerning](/Core/GlyphsCore/GSLayer-Kerning) — Spacing adjustment between specific layers.
- [GSLayer Annotations](/Core/GlyphsCore/GSLayer-Annotations) — Layer-local notes displayed with a glyph.
- [GSLayer Interpolation](/Core/GlyphsCore/GSLayer-Interpolation) — Axis coordinates and rules that place layers in a design space.
- [GSLayer Color](/Core/GlyphsCore/GSLayer-Color) — Colors used to draw a layer.
- [GSLayer Attributes](/Core/GlyphsCore/GSLayer-Attributes) — Additional values stored for a layer.
- [GSLayer Inspection](/Core/GlyphsCore/GSLayer-Inspection) — Intersections between layer outlines and line segments.
- [GSLayer Editing](/Core/GlyphsCore/GSLayer-Editing) — Operations for modifying outlines and other layer content.

