classExampleImageextendsBaseLayer { constructor(data = {}) { super(data) this.data.type = 'exampleimage'// name of layer type }
setWidth(width) { if (!width) thrownewError('Width must be provided') if (isNaN(width)) thrownewError('Width must be a number') this.data.width = width returnthis }
setHeight(height) { if (!height) thrownewError('Height must be provided') if (isNaN(height)) thrownewError('Height must be a number') this.data.height = height returnthis }
// Example of function for set image setImage(image) { if (!image) thrownewError('Image must be provided') if (!isImageUrlValid(image)) thrownewError('Image must be a valid URL') this.data.image = image returnthis } }
classExampleRectextendsBaseLayer { constructor(data = {}) { super(data) this.data.type = 'examplerect'// name of layer type }
setWidth(width) { if (!width) thrownewError('Width must be provided') if (isNaN(width)) thrownewError('Width must be a number') this.data.width = width returnthis }
setHeight(height) { if (!height) thrownewError('Height must be provided') if (isNaN(height)) thrownewError('Height must be a number') this.data.height = height returnthis }
// Example of function for set color setColor(color) { if (!color) thrownewError('Color must be provided') if (!isValidColor(color)) thrownewError('Color must be a string') this.data.color = color returnthis } }
Example