Home Reference Source
import {ShapeDefinition} from 'shapez.io/js/game/shape_definition.js'
public class | source

ShapeDefinition

Extends:

BasicSerializableObject → ShapeDefinition

Static Method Summary

Static Public Methods
public static

Generates the definition from the given short key

public static
public static

getSchema(): {}

public static

Checks if a given string is a valid short key

public static

INTERNAL Checks if a given string is a valid short key

Constructor Summary

Public Constructor
public

constructor(param0: object)

Member Summary

Public Members
public
public
public

layers: *

Method Summary

Public Methods
public

Clones the shape and colors everything in the given color

public

cloneAndPaintWith4Colors(colors: [enumColors, enumColors, enumColors, enumColors]): *

Clones the shape and colors everything in the given colors

public

Stacks the given shape definition on top.

public

Returns a definition with only the given quadrants

public

Returns a definition which was rotated 180 degrees

public

Returns a definition which was rotated counter clockwise

public

Returns a definition which was rotated clockwise

public

deserialize(data: *): *

public

drawCentered(x: number, y: number, parameters: DrawParameters, diameter: number=)

Draws the shape definition

public

drawFullSizeOnCanvas(context: CanvasRenderingContext2D, size: number)

Draws the item to a canvas

public

Generates this shape as a canvas

public

Returns a unique id for this shape

public

Internal method to clone the shape definition

public

internalGenerateShapeBuffer(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D, w: number, h: number, dpi: number)

public

Returns if the definition is entirely empty^

public

serialize(): *

Inherited Summary

From class BasicSerializableObject
public static
public static

getId()

public static

Should return the serialization schema

public static

verify(data: *): string | void

public

deserialize(data: any, root: import("./savegame_serializer").GameRoot): string | void

public

Static Public Methods

public static fromShortKey(key: string): ShapeDefinition source

Generates the definition from the given short key

Params:

NameTypeAttributeDescription
key string

Return:

ShapeDefinition

public static getId(): string source

Override:

BasicSerializableObject#getId

Return:

string

public static getSchema(): {} source

Should return the serialization schema

Override:

BasicSerializableObject#getSchema

Return:

{}

public static isValidShortKey(key: string): boolean source

Checks if a given string is a valid short key

Params:

NameTypeAttributeDescription
key string

Return:

boolean

public static isValidShortKeyInternal(key: string): boolean source

INTERNAL Checks if a given string is a valid short key

Params:

NameTypeAttributeDescription
key string

Return:

boolean

Public Constructors

public constructor(param0: object) source

Fixes typeof DerivedComponent is not assignable to typeof Component, compiled out in non-dev builds

Override:

BasicSerializableObject#constructor

Params:

NameTypeAttributeDescription
param0 object
param0.layers Array<ShapeLayer>=

Public Members

public bufferGenerator: * source

public cachedHash: string source

public layers: * source

Public Methods

public cloneAndPaintWith(color: enumColors): * source

Clones the shape and colors everything in the given color

Params:

NameTypeAttributeDescription
color enumColors

Return:

*

public cloneAndPaintWith4Colors(colors: [enumColors, enumColors, enumColors, enumColors]): * source

Clones the shape and colors everything in the given colors

Params:

NameTypeAttributeDescription
colors [enumColors, enumColors, enumColors, enumColors]

Return:

*

public cloneAndStackWith(definition: ShapeDefinition): * source

Stacks the given shape definition on top.

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

*

public cloneFilteredByQuadrants(includeQuadrants: Array<number>): ShapeDefinition source

Returns a definition with only the given quadrants

Params:

NameTypeAttributeDescription
includeQuadrants Array<number>

Return:

ShapeDefinition

public cloneRotate180(): ShapeDefinition source

Returns a definition which was rotated 180 degrees

Return:

ShapeDefinition

public cloneRotateCCW(): ShapeDefinition source

Returns a definition which was rotated counter clockwise

Return:

ShapeDefinition

public cloneRotateCW(): ShapeDefinition source

Returns a definition which was rotated clockwise

Return:

ShapeDefinition

public deserialize(data: *): * source

Override:

BasicSerializableObject#deserialize

Params:

NameTypeAttributeDescription
data *

Return:

*

public drawCentered(x: number, y: number, parameters: DrawParameters, diameter: number=) source

Draws the shape definition

Params:

NameTypeAttributeDescription
x number
y number
parameters DrawParameters
diameter number=

public drawFullSizeOnCanvas(context: CanvasRenderingContext2D, size: number) source

Draws the item to a canvas

Params:

NameTypeAttributeDescription
context CanvasRenderingContext2D
size number

public generateAsCanvas(size: number): * source

Generates this shape as a canvas

Params:

NameTypeAttributeDescription
size number

Return:

*

public getHash(): string source

Returns a unique id for this shape

Return:

string

public internalCloneLayers(): Array<ShapeLayer> source

Internal method to clone the shape definition

Return:

Array<ShapeLayer>

public internalGenerateShapeBuffer(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D, w: number, h: number, dpi: number) source

Params:

NameTypeAttributeDescription
canvas HTMLCanvasElement
context CanvasRenderingContext2D
w number
h number
dpi number

public isEntirelyEmpty(): boolean source

Returns if the definition is entirely empty^

Return:

boolean

public serialize(): * source

Override:

BasicSerializableObject#serialize

Return:

*