Home Reference Source
import {Shape} from './api/Shape.js'
public class | source

Shape

Extends:

WrappedObjectLayer → Shape

Represents a shape layer (a rectangle, oval, path, etc).

Static Method Summary

Static Public Methods
public static

tests(): dictionary

Return a list of tests to run for this class.

Constructor Summary

Public Constructor
public

constructor(shape: MSShapeGroup, document: Document)

Make a new shape object.

Member Summary

Public Members
public get

isShape: bool: boolean

Is this a shape layer?

public get

style: Style: *

Return the style of the layer.

public set

style(value: Style): *

Set the style of the layer.

Inherited Summary

From class WrappedObject
public static

tests(): dictionary

Return a list of tests to run for this class.

public get

id: string: *

Returns the object ID of the wrapped Sketch model object.

public get

Returns the wrapped Sketch object.

From class Layer
public static

tests(): dictionary

Return a list of tests to run for this class.

public get

Return the parent container of this layer.

public get

The frame of the layer.

public set

frame(frame: Rectangle): *

Set the frame of the layer.

public get

Return the index of this layer in it's container. The layer at the back of the container (visualy) will be layer 0. The layer at the front will be layer n - 1 (if there are n layers).

public get

Is this an artboard?

public get

isGroup: bool: boolean

Is this a group?

public get

isImage: bool: boolean

Is this an image layer?

public get

isPage: bool: boolean

Is this a page?

public get

isShape: bool: boolean

Is this a shape layer?

public get

isText: bool: boolean

Is this a text layer?

public get

name: string: *

The name of the layer.

public set

name(name: string): *

Set the name of the layer.

public

Add this layer to the selected layers.

public

Deselect this layer.

public

Duplicate this layer.

public

export(options: dictionary)

Export this layer (and the ones below it), using the options supplied.

public

Returns a list of export options with any missing ones replaced by default values.

public

Convert a rectangle in the coordinates that this layer uses to absolute (page) coordinates.

public

Convert a rectangle in the coordinates that this layer uses to it's parent's coordinates.

public

Move this layer backwards in its container.

public

Move this layer forward in its container.

public

Move this layer to the back of its container.

public

Move this layer to the front of its container.

public

remove()

Remove this layer from its parent.

public

select()

Select the layer.

Static Public Methods

public static tests(): dictionary source

Return a list of tests to run for this class.

Override:

Layer#tests

Return:

dictionary

A dictionary containing the tests to run. Each key is the name of a test, each value is a function which takes a Tester instance.

Public Constructors

public constructor(shape: MSShapeGroup, document: Document) source

Make a new shape object.

Params:

NameTypeAttributeDescription
shape MSShapeGroup

The underlying model object from Sketch.

document Document

The document that the shape belongs to.

Public Members

public get isShape: bool: boolean source

Is this a shape layer?

All Layer objects respond to this method, but only shape layers (rectangles, ovals, paths etc) return true.

Override:

Layer#isShape

Return:

bool

true for instances of Group, false for any other layer type.

public get style: Style: * source

Return the style of the layer.

Return:

Style

The style of the layer.

public set style(value: Style): * source

Set the style of the layer.

See something wrong or incomplete? Improve this page.