Skip to main content
Platform
Language

Shapes

In this example, we will show you how to use the CreativeEditor SDK's CreativeEngine to modify a graphic block's shape through the block API.

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.

Creating a Shape#

To create a shape simply use createShape(type: string): number.

createShape(type: ShapeType): DesignBlockId

Create a new shape, fails if type is unknown.

  • type: The type of the shape object that shall be created.
  • Returns The created shape's handle.

We currently support the following shape types:

  • '//ly.img.ubq/shape/rect'
  • '//ly.img.ubq/shape/line'
  • '//ly.img.ubq/shape/ellipse'
  • '//ly.img.ubq/shape/polygon'
  • '//ly.img.ubq/shape/star'
  • '//ly.img.ubq/shape/vector_path'

Note: short types are also accepted, e.g. 'rect' instead of '//ly.img.ubq/shape/rect'.

Functions#

You can configure shapes just like you configure design blocks. See Modify Properties for more detail.

getShape(id: DesignBlockId): DesignBlockId

Returns the block containing the shape properties of the given block.

  • id: The block whose shape block should be returned.
  • Returns The block that currently defines the given block's shape.

Destroying and Replacing Shapes#

Remember to first destroy the previous shape if you don't need it any more before changing the shape of a design block.

setShape(id: DesignBlockId, shape: DesignBlockId): void

Sets the block containing the shape properties of the given block. Note that the previous shape block is not destroyed automatically. The new shape is disconnected from its previously attached block. Required scope: 'shape/change'

  • id: The block whose shape should be changed.
  • fill: The new shape.
supportsShape(id: DesignBlockId): boolean

Query if the given block has a shape property.

  • id: The block to query.
  • Returns true, if the block has a shape property, an error otherwise.