[]
        
(Showing Draft Content)

PaintToolsPlugin

Class: PaintToolsPlugin

Paint Tools Plugin. Adds the "Paint tools", "Effects" and "Text and Objects" buttons.

Example

<script src="dsimageviewer.js"></script></head>
<script src="plugins/paintTools.js"></script>
<script>
  const viewer = new DsImageViewer("#root");
  viewer.addPlugin(new PaintToolsPlugin());
</script>

Properties

viewer

viewer: ImageViewerAPI;

Gets the image viewer instance. The image viewer instance.

Implementation of

PaintToolsPluginAPI.viewer

options

options: PaintToolsPluginOptions;

Plugin options passed at construction time.

Implementation of

PaintToolsPluginAPI.options

toolsOptions

toolsOptions: Required<ToolsOptions>;

Gets or sets the default visual properties for each paint and object tool at runtime.

Reading this property returns the last value set either via the constructor option toolsOptions or by a previous assignment.

Setting this property immediately:

  • updates the paint toolbar state (size, color, opacity, hardness for Pencil, Brush, Eraser, Clone Stamp, and Text),
  • updates the default style applied to newly created shape objects (Rectangle, Line, Arrow, Circle, Brackets, Image).

Previously placed objects and the user's own interactive adjustments are not affected.

Example

// Change arrow and pencil defaults after the viewer has opened
const plugin = viewer.findPlugin('paintTools');
plugin.toolsOptions = {
  lineWidth: 3,
  lineColor: '#cc0000',
  penSize: 5,
  penColor: '#333333',
};

Implementation of

PaintToolsPluginAPI.toolsOptions

effectsToolbarLayout

effectsToolbarLayout: ToolbarItemType[];

Returns the resolved item layout for the Effects toolbar. Reflects toolbarLayout.effectsTools from plugin options: true/undefined/null → default layout; false → empty array; array → used as-is.

See

Implementation of

PaintToolsPluginAPI.effectsToolbarLayout

paintToolbarLayout

paintToolbarLayout: ToolbarItemType[];

Returns the layout for the effects tools toolbar. If the value is true, undefined, or null, a default layout is returned. If the value is false, an empty layout is returned. Otherwise, the provided custom layout is used.

See

Implementation of

PaintToolsPluginAPI.paintToolbarLayout

textToolbarLayout

textToolbarLayout: ToolbarItemType[];

Returns the layout for the effects tools toolbar. If the value is true, undefined, or null, a default layout is returned. If the value is false, an empty layout is returned. Otherwise, the provided custom layout is used.

See

Implementation of

PaintToolsPluginAPI.textToolbarLayout

objectsToolbarLayout

objectsToolbarLayout: ToolbarItemType[];

Returns the layout for the effects tools toolbar. If the value is true, undefined, or null, a default layout is returned. If the value is false, an empty layout is returned. Otherwise, the provided custom layout is used.

See

Implementation of

PaintToolsPluginAPI.objectsToolbarLayout

paintLayer

paintLayer: ImageLayer;

Gets the paint layer containing the HTML canvas for drawing the image.

Implementation of

PaintToolsPluginAPI.paintLayer

isReady

isReady: boolean;

Returns true if the image is loaded into the viewer and the image format is supported by the Image Filters plugin.

Implementation of

PaintToolsPluginAPI.isReady

naturalSize

naturalSize: Size;

Natural image size.

Implementation of

PaintToolsPluginAPI.naturalSize

id

id: PluginType;

Unique plug-in identifier.

Implementation of

PaintToolsPluginAPI.id

Methods

isImageFormatSupported()

isImageFormatSupported(imageFormat, allowUnknown?): boolean;

Determines whether the specified image format is supported for modifications.

Parameters

imageFormat

The image format to check, either as an enum value or string.

string | ImageFormatCode

allowUnknown?

boolean

If true, allows unknown formats (ImageFormatCode.Default) to be considered supported.

Returns

boolean

True if the format is supported for modifications, false otherwise.

Remarks

The following formats are explicitly not supported:

  • TIFF (ImageFormatCode.TIFF)
  • SVG (ImageFormatCode.SVG)
  • ICO (ImageFormatCode.ICO)
  • GIF (ImageFormatCode.GIF)

Examples

// Check if PNG is supported
const supported = isImageFormatSupported(ImageFormatCode.PNG);
// Check if an unknown format is supported (returns false by default)
const supported = isImageFormatSupported('custom-format');
// Check if an unknown format is supported (returns true when allowUnknown is true)
const supported = isImageFormatSupported('custom-format', true);

Implementation of

PaintToolsPluginAPI.isImageFormatSupported

dispose()

dispose(): void;

Cleans up resources and disposes the plugin.

Returns

void

Implementation of

PaintToolsPluginAPI.dispose

removePaintLayer()

removePaintLayer(): void;

Removes and disposes the active paint layer. If no paint layer exists, this method does nothing.

Returns

void

Implementation of

PaintToolsPluginAPI.removePaintLayer

initialize()

initialize(viewer): void;

The method is called when the GcImageViewer component is initialized.

Parameters

viewer

ImageViewerAPI

Returns

void

Implementation of

PaintToolsPluginAPI.initialize