# `GSShape`

*Class*

An abstract base class for graphical elements stored in a glyph layer.

## Declaration

```swift
class GSShape
```

```objc
@interface GSShape : GSBaseObject
```

```python
class GSShape(GSBaseObject)
```

## Overview

Shapes are stacked to form the composition of a [`GSLayer`](/Core/GlyphsCore/GSLayer).

When the parent (layer) of a shape is not set, many of it’s APIs cannot work to their full extend. This is because a shape frequently needs to reference layer metrics, glyph properties, for other font metadata.

## Topics

### Concrete Subclasses

- [`GSPath`](/Core/GlyphsCore/GSPath) — A graphical path made of nodes.
- [`GSComponent`](/Core/GlyphsCore/GSComponent) — A reference to another glyph placed as a shape in a glyph layer.
- [`GSShapeGroup`](/Core/GlyphsCore/GSShapeGroup) — A shape group combines zero or more shapes into a single shape, forming a shape tree.

### Creating a Shape

- [`GSShape initWithDict:format:`](/Core/GlyphsCore/GSShape/initWithDict:format:) — Creates a concrete shape from a Glyphs file dictionary representation.
- [`GSShape postRead:format:`](/Core/GlyphsCore/GSShape/postRead:format:) — Finishes loading after the shape has been attached to its layer.

### Type and Comparison

- [`GSShapeType`](/Core/GlyphsCore/GSShapeType) — The kind of content represented by a shape.
- [`GSShape.shapeType`](/Core/GlyphsCore/GSShape/shapeType) — The kind of content represented by the concrete shape.
- [`GSShape compareString`](/Core/GlyphsCore/GSShape/compareString) — A structural description used to determine layer compatibility.
- [`GSShape isEqualToShape:`](/Core/GlyphsCore/GSShape/isEqualToShape:) — Whether another shape has the same concrete class.

### Shape Hierarchy

- [`GSShape.parentGroupId`](/Core/GlyphsCore/GSShape/parentGroupId) — The ID of the parent group.
- [`GSShape.parentGroup`](/Core/GlyphsCore/GSShape/parentGroup) — The direct containing group in the layer’s shape hierarchy.
- [`GSShape enumerateParentGroupsWithBlock:`](/Core/GlyphsCore/GSShape/enumerateParentGroupsWithBlock:) — Invokes a block for each containing group, from the direct parent through the root group.

### Naming

- [`GSShape.nameUI`](/Core/GlyphsCore/GSShape/nameUI) — An optional label for identifying the shape in user interfaces.

### Geometry

- [`GSShape transform:`](/Core/GlyphsCore/GSShape/transform:) — Applies an affine transformation to the complete shape.
- [`GSShape transform:selection:`](/Core/GlyphsCore/GSShape/transform:selection:) — Applies an affine transformation to selected elements of the shape.
- [`GSShape transformFast:grid:`](/Core/GlyphsCore/GSShape/transformFast:grid:) — Applies an affine transformation and aligns the resulting coordinates to a grid without registering undo or notifying the layer.
- [`GSShape moveWithPoint:`](/Core/GlyphsCore/GSShape/moveWithPoint:) — Translates the complete shape by an offset.
- [`GSShape getPositionsFromShape:`](/Core/GlyphsCore/GSShape/getPositionsFromShape:) — Copies corresponding positions and transformation values from another shape.

### Drawing

- [`GSShape drawInPen:`](/Core/GlyphsCore/GSShape/drawInPen:) — Writes the shape to a pen.
- [`GSShape drawInPen:openPen:secondaryPen:extraHandles:`](/Core/GlyphsCore/GSShape/drawInPen:openPen:secondaryPen:extraHandles:) — Writes the shape to separate pens for closed paths, open paths, and auxiliary output.
- [`GSShape drawSimpleInPen:`](/Core/GlyphsCore/GSShape/drawSimpleInPen:) — Writes the basic shape representation to a pen without resolving path decorations.
- [`GSShape drawSimpleInPen:fast:`](/Core/GlyphsCore/GSShape/drawSimpleInPen:fast:) — Writes the basic shape representation to a pen, optionally omitting segment object information.

### Fill Paint

- [`GSShape.fillPaint`](/Core/GlyphsCore/GSShape/fillPaint) — The effective fill paint.
- [`GSShape.fillColor`](/Core/GlyphsCore/GSShape/fillColor) — The solid color used for the fill.
- [`GSShape.fillGradient`](/Core/GlyphsCore/GSShape/fillGradient) — The gradient used for the fill.

### Stroke Style

- [`GSShape.strokeWidth`](/Core/GlyphsCore/GSShape/strokeWidth) — The horizontal size expression used to expand the path into a stroke.
- [`GSShape.strokeHeight`](/Core/GlyphsCore/GSShape/strokeHeight) — The vertical size expression used to expand the path into a stroke.
- [`GSShape.strokePosition`](/Core/GlyphsCore/GSShape/strokePosition) — The stroke position from `-1` on the left to `1` on the right of the path direction.
- [`GSLineCapStyle`](/Core/GlyphsCore/GSLineCapStyle) — The construction used at an open stroke endpoint.
- [`GSShape.lineCapStart`](/Core/GlyphsCore/GSShape/lineCapStart) — The cap at the start of an open path.
- [`GSShape.lineCapEnd`](/Core/GlyphsCore/GSShape/lineCapEnd) — The cap at the end of an open path.
- [`GSLineJoinStyle`](/Core/GlyphsCore/GSLineJoinStyle) — The construction used to connect consecutive stroke segments.
- [`GSShape.lineJoin`](/Core/GlyphsCore/GSShape/lineJoin) — The construction used to connect consecutive stroke segments.
- [`GSShape.filled`](/Core/GlyphsCore/GSShape/filled) — Whether the path remains filled when it has a stroke.
- [`GSShape getStrokeSettingsWidth:height:pos:capStart:capEnd:join:fill:maskType:`](/Core/GlyphsCore/GSShape/getStrokeSettingsWidth:height:pos:capStart:capEnd:join:fill:maskType:) — Reads the shape’s stroke style into optional output parameters.

### Stroke Paint

- [`GSShape.strokePaint`](/Core/GlyphsCore/GSShape/strokePaint) — The effective stroke paint.
- [`GSShape.strokeColor`](/Core/GlyphsCore/GSShape/strokeColor) — The solid color used for the stroke.
- [`GSShape.strokeGradient`](/Core/GlyphsCore/GSShape/strokeGradient) — The gradient used for the stroke.

### Compositing

- [`GSShape.hidden`](/Core/GlyphsCore/GSShape/hidden) — Whether the shape is excluded from drawing and generated outlines.
- [`GSShape.opacity`](/Core/GlyphsCore/GSShape/opacity) — The alpha applied to the complete rendered shape.
- [`GSShape.compositingOperation`](/Core/GlyphsCore/GSShape/compositingOperation) — How the rendered shape is combined with the content behind it.
- [`GSShape.outerShadow`](/Core/GlyphsCore/GSShape/outerShadow) — The shadow cast by the shape.
- [`GSShape.innerShadow`](/Core/GlyphsCore/GSShape/innerShadow) — The shadow drawn inside the shape.

### Masking

- [`GSMaskType`](/Core/GlyphsCore/GSMaskType) — How a shape masks preceding shapes in the same composition unit.
- [`GSShape.maskType`](/Core/GlyphsCore/GSShape/maskType) — How the shape masks the preceding shape or shapes in the same composition unit.

### Attributes

- [`GSShape scaleAttributes:`](/Core/GlyphsCore/GSShape/scaleAttributes:) — Scales the stroke width and explicit stroke height by a factor.

### Constants

- [GSShape Constants](/Core/GlyphsCore/GSShape-Constants)

## Relationships

### Inherits From

- [`GSBaseObject`](/Core/GlyphsCore/GSBaseObject)

### Inherited By

- [`GSPath`](/Core/GlyphsCore/GSPath)
- [`GSShapeGroup`](/Core/GlyphsCore/GSShapeGroup)
- [`GSTransformableElement`](/Core/GlyphsCore/GSTransformableElement)

## See Also

### Shapes

- [`GSPath`](/Core/GlyphsCore/GSPath) — A graphical path made of nodes.
- [`GSComponent`](/Core/GlyphsCore/GSComponent) — A reference to another glyph placed as a shape in a glyph layer.
- [`GSShapeGroup`](/Core/GlyphsCore/GSShapeGroup) — A shape group combines zero or more shapes into a single shape, forming a shape tree.

