Skip to main content
Platform
Language

Cutout

In this example, we will show you how to use the CreativeEditor SDK's CreativeEngine block and editor API to create and modify a cutout block. Cutout blocks can be created from an SVG path or by performing boolean operations on existing multiple cutout blocks. One can then change a cutout's offset from its underlying path and its type.

By default, a cutout's color is set by a spot color. Cutouts of type Solid use the spot color "CutContour" and cutouts of type Dashed use the spot color "PerfCutContour". One can change these defaults to other spot colors.

Setup#

This example uses the headless CreativeEngine. See the Setup article for a detailed guide. To get started right away, you can also access the block API within a running CE.SDK instance via cesdk.engine.block. Check out the APIs Overview to see that illustrated in more detail.

Functions#

createCutoutFromPath(path: string): DesignBlockId

Create a Cutout block.

  • path: An SVG string describing a path.
  • Returns The newly created block or an error.
createCutoutFromBlocks(ids: DesignBlockId[], vectorizeDistanceThreshold?: number, simplifyDistanceThreshold?: number): DesignBlockId

Creates a cutout whose path will be the contour of the given blocks. The cutout path for each element is derived from one two ways: - Blocks that have already have a vector path (shapes, SVG-based text or stickers). - Blocks that don't have a vector path are vectorized and then, optionally, simplified to eliminate jaggedness (images).

  • blocks: The blocks whose shape will serve as the basis for the cutout's path.
  • vectorizeDistanceThreshold: The maximum number of pixels by which the cutout's path can deviate from the original contour.
  • simplifyDistanceThreshold: The maximum number of pixels by which the simplified cutout path can deviate from the cutout contour. If 0, no simplification step is performed.
  • Returns The newly created block or an error.
createCutoutFromOperation(ids: DesignBlockId[], op: CutoutOperation): DesignBlockId

Perform a boolean operation on the given Cutout blocks. The cutout offset of the new block is 0. The cutout type of the new block is that of the first block. When performing a Difference operation, the first block is the block subtracted from.

  • blocks: The blocks with which to perform to the operation.
  • op: The boolean operation to perform.
  • Returns The newly created block or an error.
setSpotColorForCutoutType(type: CutoutType, color: string): void

Set the spot color assign to a cutout type. All cutout blocks of the given type will be immediately assigned that spot color.

  • type: The cutout type.
  • name: The spot color name to assign.
getSpotColorForCutoutType(type: CutoutType): string

Get the name of the spot color assigned to a cutout type.

  • type: The cutout type.
  • Returns The color spot name.