Readonly heightThe height of the canvas in pixels. This is the field height multiplied by the scale factor defined for the custom field.
Readonly widthThe width of the canvas. This is the field with multiplied by the scale factor defined for the custom field.
Serialize the drawing commands issued so far into the field definition. The field will then reflect the drawing commands when rendered.
Optional target: CustomFieldDrawingCommandTargetThe target defines which canvas to write to. The default is the data canvas.
Optional callback: (() => void)The callback will be triggered once the field has been written to. This may be asynchronous if images have to be saved.
Generate the 2d drawing context. This is of type CanvasRenderingContext2D https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
The drawing context can be used almost normally with a few exceptions:
Must be "2d"
Generate a blob object from the canvas
The callback to call when the blob is ready
Optional type: stringThe type of the blob - defaults to "image/png" - see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob
Optional encoderOptions: numberOptional encoder options when the type supports them (e.g. JPEG or webp)
Converts the canvas to a data url.
Optional type: stringOptional type - defaults to "image/png" - see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL
Optional encoderOptions: numberOptional encoder options when the type supports them (e.g. JPEG or webp)
Generated using TypeDoc
A custom field canvas can be used to draw on a custom field using the standard canvas drawing commands in Javascript. The output would be rendered as vector where possible and it will support the color format of MegaEdit, not just RGB.