# GSLayer Drawing

*API Collection*

Create render representations and emit layer contents to pens.

## Overview

The Bézier path properties are derived representations for drawing and inspection. Modifying them does not modify the layer’s shapes.

Pen drawing emits outline commands to an object conforming to [`GSPenProtocol`](/Core/GlyphsCore/GSPenProtocol). Use a separate open pen when open paths must be collected independently.

Draw stacks additionally preserve paint, masks, strokes, transforms, and composition structure according to the features supported by their consumer.

Call [`GSLayer prepareDrawing`](/Core/GlyphsCore/GSLayer/prepareDrawing) and [`GSLayer finishDrawing`](/Core/GlyphsCore/GSLayer/finishDrawing) around direct drawing of the layer’s shape hierarchy when path component hints must be applied. Bézier path generation manages this preparation as needed.

## Topics

### Bezier Paths

- [`GSLayer.bezierPath`](/Core/GlyphsCore/GSLayer/bezierPath) — A cached representation of the layer’s closed path shapes.
- [`GSLayer.openBezierPath`](/Core/GlyphsCore/GSLayer/openBezierPath) — A cached representation of the layer’s open path shapes.
- [`GSLayer.selectionPath`](/Core/GlyphsCore/GSLayer/selectionPath) — A cached representation of the selected outline segments.
- [`GSLayer drawBezierPath`](/Core/GlyphsCore/GSLayer/drawBezierPath) — A representation of the closed paths and component outlines.
- [`GSLayer drawBezierPath:hasPaths:`](/Core/GlyphsCore/GSLayer/drawBezierPath:hasPaths:) — Creates a representation of the closed paths and component outlines while tracking component recursion.
- [`GSLayer drawOpenBezierPath`](/Core/GlyphsCore/GSLayer/drawOpenBezierPath) — A representation of the open paths in the layer and its components.
- [`GSLayer drawOpenBezierPathFast`](/Core/GlyphsCore/GSLayer/drawOpenBezierPathFast) — Returns the cached representation of open paths without updating it.

### Drawing State

- [`GSLayer.secondaryPath`](/Core/GlyphsCore/GSLayer/secondaryPath) — Auxiliary outlines generated by the most recent full Bézier path preparation.
- [`GSLayer.extraHandles`](/Core/GlyphsCore/GSLayer/extraHandles) — Interactive handles generated by the most recent full Bézier path preparation.
- [`GSLayer.currentDrawingAttributes`](/Core/GlyphsCore/GSLayer/currentDrawingAttributes) — The shape attributes applied to newly drawn shapes.
- [`GSLayer setCurrentDrawingAttribute:forKey:`](/Core/GlyphsCore/GSLayer/setCurrentDrawingAttribute:forKey:) — Sets or removes an attribute applied to newly drawn shapes.
- [`GSLayer addCurrentDrawingAttributes:`](/Core/GlyphsCore/GSLayer/addCurrentDrawingAttributes:) — Adds shape attributes applied to newly drawn shapes.
- [`GSLayer prepareDrawing`](/Core/GlyphsCore/GSLayer/prepareDrawing) — Prepares path component hints for direct pen drawing.
- [`GSLayer finishDrawing`](/Core/GlyphsCore/GSLayer/finishDrawing) — Finishes direct pen drawing prepared by [`GSLayer prepareDrawing`](/Core/GlyphsCore/GSLayer/prepareDrawing).

### Draw Stack

- [`GSLayer drawStack`](/Core/GlyphsCore/GSLayer/drawStack) — The painted drawing operations for the complete layer.
- [`GSLayer drawStackForGroup:supporting:penClass:secondaryPen:extraHandles:`](/Core/GlyphsCore/GSLayer/drawStackForGroup:supporting:penClass:secondaryPen:extraHandles:) — Creates painted drawing operations for a shape group.

### Pen Drawing

- [`GSLayer drawInPen:`](/Core/GlyphsCore/GSLayer/drawInPen:) — Emits the layer to a pen.
- [`GSLayer drawInPen:openPen:`](/Core/GlyphsCore/GSLayer/drawInPen:openPen:) — Emits the layer to separate pens for closed and open paths.
- [`GSLayer drawSimpleInPen:`](/Core/GlyphsCore/GSLayer/drawSimpleInPen:) — Emits the layer’s shapes without layer-level paint processing.
- [`GSLayer drawBlackInPen:openPen:`](/Core/GlyphsCore/GSLayer/drawBlackInPen:openPen:) — Emits the layer without full-color paint processing.
- [`GSLayer drawColorInPen:`](/Core/GlyphsCore/GSLayer/drawColorInPen:) — Emits the painted drawing operations of a full-color layer to a pen.
- [`GSLayer drawDrawStack:inPen:`](/Core/GlyphsCore/GSLayer/drawDrawStack:inPen:) — Emits the path and error operations of a draw stack to a pen.

## See Also

- [GSLayer Kind](/Core/GlyphsCore/GSLayer-Kind) — The different roles that a layer can serve.
- [GSLayer Shapes](/Core/GlyphsCore/GSLayer-Shapes) — The paths and components that form the outline of a layer.
- [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.

