Document Solutions Image Viewer
    Preparing search index...

    Class PaintToolsPlugin

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

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

    Constructors

    Methods

    • Determines whether the specified image format is supported for modifications.

      Parameters

      • imageFormat: string | ImageFormatCode

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

      • OptionalallowUnknown: boolean

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

      Returns boolean

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

      The following formats are explicitly not supported:

      • TIFF (ImageFormatCode.TIFF)
      • SVG (ImageFormatCode.SVG)
      • ICO (ImageFormatCode.ICO)
      • GIF (ImageFormatCode.GIF)
      // 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);
    • Cleans up resources and disposes the plugin.

      Returns void

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

      Returns void

    • The method is called when the GcImageViewer component is initialized.

      Parameters

      Returns void

    Properties

    Gets the image viewer instance. The image viewer instance.

    Plugin options passed at construction time.

    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.

    // 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',
    };
    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.

    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.

    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.

    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.

    paintLayer: ImageLayer

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

    isReady: boolean

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

    naturalSize: Size

    Natural image size.

    Unique plug-in identifier.