ComPDFKit Web SDK
    Preparing search index...

    Class CanvasHelper

    Drawing helpers for custom annotation drawing; they use the current stroke style, fill style and line width of the context.

    Index
    • Creates a helper drawing into a canvas context.

      Parameters

      • ctx: CanvasRenderingContext2D

        The canvas context to draw into.

      Returns CanvasHelper

    • Clears the whole canvas (unaffected by the current transform).

      Returns void

    • Strokes a circle given by center coordinates.

      Parameters

      • x: number

        X of the center.

      • y: number

        Y of the center.

      • radius: number

        Radius.

      Returns void

    • Cloudy edge: semicircular arcs along each edge of the closed polygon, with a diameter of about intensity × 10.

      Parameters

      Returns void

    • Strokes a line between two points given by coordinates.

      Parameters

      • x1: number

        X of the start point.

      • y1: number

        Y of the start point.

      • x2: number

        X of the end point.

      • y2: number

        Y of the end point.

      Returns void

    • Strokes a polygon or polyline through the points; does nothing without points.

      Parameters

      • points: Core.Annotations.Point[]

        The vertices.

      • Optionalclosed: boolean

        Whether to close the path back to the first point; defaults to true.

      Returns void

    • Fills text at a position.

      Parameters

      • text: string

        The text.

      • x: number

        X of the text baseline start.

      • y: number

        Y of the text baseline.

      • Optionalfont: Font

        Font to use (name and size in pixels); the current context font when omitted.

      Returns void

    • Measures text.

      Parameters

      • text: string

        The text.

      • Optionalfont: Font

        Font to use (name and size in pixels); the current context font when omitted.

      Returns { height: number; width: number }

      Width and height of the text in pixels.

      • height: number

        Height in pixels (ascent plus descent).

      • width: number

        Width in pixels.

    ctx: CanvasRenderingContext2D

    The canvas context to draw into.