Class

SKShapeNode

A mathematical shape that can be stroked or filled.

Declaration

@interface SKShapeNode : SKNode

Overview

SKShapeNode allows you to create onscreen graphical elements from mathematical points, lines, and curves. The advantage this has over rasterized graphics, such as those displayed by textures, is that shapes are rasterized dynamically at runtime to produce crisp detail and smoother edges.

Topics

First Steps

Getting Started with Shape Nodes

Create a filled or stroked shape from a path object.

Creating a Shape from a Path

+ shapeNodeWithPath:

Creates a shape node from a Core Graphics path.

+ shapeNodeWithPath:centered:

Creates a shape node from a Core Graphics path, centered around its position.

path

The path that defines the shape.

Creating a Shape from a Rectangle

+ shapeNodeWithRect:

Creates a shape node with a rectangular path.

+ shapeNodeWithRectOfSize:

Creates a shape node with a rectangular path centered on the node’s origin.

+ shapeNodeWithRect:cornerRadius:

Creates a shape with a rectangular path that has rounded corners.

+ shapeNodeWithRectOfSize:cornerRadius:

Creates a shape with a rectangular path that has rounded corners centered on the node’s position.

Creating a Circle Shape

+ shapeNodeWithCircleOfRadius:

Creates a shape node with a circular path centered on the node’s origin.

Creating an Ellipse Shape

+ shapeNodeWithEllipseOfSize:

Creates a shape node with an elliptical path centered on the node’s origin.

+ shapeNodeWithEllipseInRect:

Creates a shape node with an elliptical path that fills the specified rectangle.

Creating a Shape from an Array of Points

Creating a Shape Node from an Array of Points

Create jagged or smooth shapes from the same array of points.

+ shapeNodeWithPoints:count:

Creates a shape node from a series of points.

+ shapeNodeWithSplinePoints:count:

Creates a shape node from a series of spline points.

Filling a Shape

fillColor

The color used to fill the shape.

fillTexture

The texture used to fill the shape.

Stroking a Shape

lineWidth

The width used to stroke the path.

strokeColor

The color used to stroke the shape.

strokeTexture

The texture used to stroke the shape.

glowWidth

A glow that extends outward from the stroked line.

lineCap

The style used to render the endpoints of the stroked portion of the shape node.

lineJoin

The junction type used when the stroked portion of the shape node is rendered.

miterLimit

The miter limit to use when the line is stroked using a miter join style.

antialiased

A Boolean value that determines whether the stroked path is smoothed when drawn.

Configuring Alpha Blending

Change how a shape uses its alpha value, such as additive blending, that results in the shape being brighter than it was before.

blendMode

The blend mode used to blend the shape into the parent’s framebuffer.

Controlling or Animating Sroke Length

Adjust or animate a shape's stroke.

lineLength

The length of the line defined by the shape node.

Customizing Stroking or Fill Drawing

Take per-pixel control of drawing the stroke or fill by supplying a custom code file.

Controlling Shape Drawing with Shaders

Change a shape node's appearance by supplying custom shader code.

strokeShader

A custom shader used to determine the color of the stroked portion of the shape node.

fillShader

A custom shader used to determine the color of the filled portion of the shape node.

attributeValues

The values of each attribute associated with the node's attached shader.

- setValue:forAttributeNamed:

Sets an attribute value for an attached shader.

- valueForAttributeNamed:

The value of a shader attribute.

Relationships

Inherits From

See Also

Nodes that Draw

Maximizing Node Drawing Performance

Structure your nodes for maximum performance.

SKSpriteNode

An image or solid color.

SKEmitterNode

A source of various particle effects.

SKLabelNode

A graphical element that draws text.

SKVideoNode

A graphical element that plays video content.

SKTileMapNode

A two-dimensional array of images.

SK3DNode

3D SceneKit content drawn as a flattened sprite.