<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PaperKit",
  "identifier" : "/documentation/PaperKit/ShapeMarkup",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "PaperKit"
    ],
    "preciseIdentifier" : "s:8PaperKit11ShapeMarkupV"
  },
  "title" : "ShapeMarkup"
}
-->

# ShapeMarkup

A markup element that represents a shape or text box with customizable appearance and behavior.

```
struct ShapeMarkup
```

## Overview

Use `ShapeMarkup` to add geometric shapes, lines, and text containers to your markup content.
Shapes can be filled, stroked, rotated, and configured with various visual properties.

```swift
// Create a filled rectangle
let rect = ShapeMarkup(
    shape: .rectangle,
    frame: CGRect(x: 0, y: 0, width: 100, height: 50),
    fillColor: CGColor(red: 0, green: 0, blue: 1, alpha: 1)
)

// Create a resizable textbox
var textBox = ShapeMarkup(
    shape: .rectangle,
    frame: CGRect(x: 0, y: 0, width: 80, height: 80),
    attributedText: AttributedString("Star!"),
    autoresizing: [.flexibleWidth]
)
textBox.attributedText = AttributedString("This text will cause the box to expand")

// Create an arrow line
let arrow = ShapeMarkup(
    shape: .line(start: .zero, control: CGPoint(x: 0.5, y: 0), end: CGPoint(x: 1, y: 0)),
    frame: CGRect(x: 0, y: 0, width: 200, height: 2),
    strokeColor: CGColor(red: 0, green: 0, blue: 0, alpha: 1),
    endLineMarker: .arrow
)
```

## Topics

### Creating a shape

[`init(configuration: ShapeConfiguration, frame: CGRect, rotation: CGFloat)`](/documentation/PaperKit/ShapeMarkup/init(configuration:frame:rotation:))

Initializes and returns a new shape markup from the specified parameters.

[`init(shape: ShapeMarkup.Shape, frame: CGRect, rotation: CGFloat, fillColor: CGColor?, strokeColor: CGColor?, lineWidth: CGFloat, opacity: CGFloat, startLineMarker: ShapeMarkup.LineMarker, endLineMarker: ShapeMarkup.LineMarker, attributedText: AttributedString, allowedInteractions: MarkupInteractions, autoresizing: MarkupAutoresizing, id: MarkupID<ShapeMarkup>)`](/documentation/PaperKit/ShapeMarkup/init(shape:frame:rotation:fillColor:strokeColor:lineWidth:opacity:startLineMarker:endLineMarker:attributedText:allowedInteractions:autoresizing:id:))

Initializes and returns a new shape markup from the specified parameters.

### Choosing a shape type

[`var shape: ShapeMarkup.Shape`](/documentation/PaperKit/ShapeMarkup/shape-swift.property)

The type of the shape.

[`var shapeScaled: ShapeMarkup.Shape`](/documentation/PaperKit/ShapeMarkup/shapeScaled)

The type of the shape with values scaled to the current frame.

[`enum Shape`](/documentation/PaperKit/ShapeMarkup/Shape-swift.enum)

### Configuring fill and stroke

[`var fillColor: CGColor?`](/documentation/PaperKit/ShapeMarkup/fillColor)

The color used to fill the shape’s path.

[`var strokeColor: CGColor?`](/documentation/PaperKit/ShapeMarkup/strokeColor)

The color used to stroke the shape’s path.

[`var lineWidth: CGFloat`](/documentation/PaperKit/ShapeMarkup/lineWidth)

The line width of the shape’s path.

[`var opacity: CGFloat`](/documentation/PaperKit/ShapeMarkup/opacity)

The opacity of the shape.

### Configuring text

[`var attributedText: AttributedString`](/documentation/PaperKit/ShapeMarkup/attributedText)

The attributed text displayed inside this shape.

### Configuring line markers

[`var startLineMarker: ShapeMarkup.LineMarker`](/documentation/PaperKit/ShapeMarkup/startLineMarker)

The line marker used at the start of an open shape path.

[`var endLineMarker: ShapeMarkup.LineMarker`](/documentation/PaperKit/ShapeMarkup/endLineMarker)

The line marker used at the end of an open shape path.

[`enum LineMarker`](/documentation/PaperKit/ShapeMarkup/LineMarker)

A marker that can be attached to a line.

### Configuring sizing

[`var autoresizing: MarkupAutoresizing`](/documentation/PaperKit/ShapeMarkup/autoresizing)

Automatic sizing behaviors for this markup.

### Identifying markup

[`var id: MarkupID<ShapeMarkup>`](/documentation/PaperKit/ShapeMarkup/id)

Stable unique identity of the markup.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Identifiable`](/documentation/Swift/Identifiable)

[`Markup`](/documentation/PaperKit/Markup)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)