marker.js 3 Documentation
    Preparing search index...

    Class MarkerBase

    Base class for all markers.

    When creating custom marker types usually you will want to extend one of the derived classes. However, if you cannot find a suitable base class, you can and you should extend this class.

    Hierarchy (View Summary)

    Index

    Accessors

    Constructors

    Methods

    • Applies the fill color to the marker's visual.

      Override this method in a derived class to apply the color to the marker's visual.

      Returns void

    • Applies the opacity to the marker's visual.

      Override this method in a derived class to apply the opacity to the marker's visual

      Returns void

    • Applies the stroke color to the marker's visual.

      Override this method in a derived class to apply the color to the marker's visual.

      Returns void

    • Applies the stroke dash array to the marker's visual.

      Override this method in a derived class to apply the dash array to the marker's visual.

      Returns void

    • Applies the stroke width to the marker's visual.

      Override this method in a derived class to apply the width to the marker's visual.

      Returns void

    • Returns markers bounding box.

      Override to return a custom bounding box.

      Returns DOMRect

      rectangle fitting the marker.

    • When overridden in a derived class, represents a preliminary outline for markers that can be displayed before the marker is actually created.

      Returns string

      SVG path string.

    • Returns true if passed SVG element belongs to the marker. False otherwise.

      Parameters

      • el: EventTarget

        target element.

      Returns boolean

      true if the element belongs to the marker.

    • Scales marker. Used after resize.

      Parameters

      • scaleX: number

        horizontal scale

      • scaleY: number

        vertical scale

      Returns void

    Properties

    _container: SVGGElement

    SVG container object holding the marker's visual.

    It is created and passed to the constructor by marker editor or viewer when creating the marker.

    _fillColor: string = 'transparent'

    Fill color of the marker.

    _opacity: number = 1

    Opacity of the marker.

    _strokeColor: string = 'transparent'

    Stroke (outline) color of the marker.

    _strokeDasharray: string = ''

    Stroke (outline) dash array of the marker.

    _strokeWidth: number = 0

    Stroke (outline) width of the marker.

    applyDefaultFilter: boolean = true

    When true, the default filter is applied to the marker's visual.

    3.2.0

    defaultSize: ISize = ...

    The default marker size when the marker is created with a click (without dragging).

    notes?: string

    Additional information about the marker.

    Generally, this isn't used for anything functional. However, in a derived type it could be used for storing arbitrary data with no need to create extra properties and state types.

    stage: MarkerStage = 'normal'

    Marker lifecycle stage.

    Most markers are created immediately after the user clicks on the canvas (normal). However, some markers are only finished creating after additional interactions (creating).

    title: string

    Marker type title (display name) used for accessibility and other attributes.

    typeName: string = 'MarkerBase'

    Marker type name.

    It's important to set this in each derived class. This value is used to identify marker types when restoring marker state and other scenarios.