hammerspoon2-docs
    Preparing search index...

    Interface HSCanvasElement

    One element drawn on a canvas. Only type is required; see the canvas guide for what each attribute does and which element types read it. Positions and sizes are numbers of points, or percentage strings such as "50%" of the canvas's size

    interface HSCanvasElement {
        action?: "fill" | "stroke" | "strokeAndFill" | "build" | "clip" | "skip";
        arcClockwise?: boolean;
        arcRadii?: boolean;
        canvas?: HSCanvas;
        canvasAlpha?: number;
        center?: { x?: string | number; y?: string | number };
        closed?: boolean;
        compositeRule?: string;
        coordinates?: {
            c1x?: string | number;
            c1y?: string | number;
            c2x?: string | number;
            c2y?: string | number;
            x?: string | number;
            y?: string | number;
        }[];
        endAngle?: number;
        fillColor?: string
        | HSColor
        | HSCanvasColor;
        fillGradient?: "linear" | "radial";
        fillGradientAngle?: number;
        fillGradientCenter?: { x?: string | number; y?: string | number };
        fillGradientColors?: (string | HSColor | HSCanvasColor)[];
        frame?: {
            h?: string | number;
            w?: string | number;
            x?: string | number;
            y?: string | number;
        };
        id?: any;
        image?: HSImage;
        imageAlignment?: | "left"
        | "right"
        | "center"
        | "top"
        | "bottom"
        | "topLeft"
        | "topRight"
        | "bottomLeft"
        | "bottomRight";
        imageAlpha?: number;
        imageScaling?: | "none"
        | "scaleToFit"
        | "scaleProportionally"
        | "shrinkToFit";
        radius?: string
        | number;
        reversePath?: boolean;
        rotation?: number;
        rotationPoint?: { x?: string | number; y?: string | number };
        roundedRectRadii?: number | { xRadius?: number; yRadius?: number };
        startAngle?: number;
        strokeColor?: string | HSColor | HSCanvasColor;
        strokeWidth?: number;
        text?: string;
        textAlignment?: "left" | "right" | "center" | "justified" | "natural";
        textColor?: string | HSColor | HSCanvasColor;
        textDesign?: "monospaced" | "rounded" | "serif";
        textFont?: string;
        textItalic?: boolean;
        textLineBreak?:
            | "clip"
            | "wordWrap"
            | "charWrap"
            | "truncateHead"
            | "truncateMiddle"
            | "truncateTail";
        textSize?: number;
        textWeight?: | "bold"
        | "medium"
        | "thin"
        | "ultraLight"
        | "light"
        | "regular"
        | "semibold"
        | "heavy"
        | "black";
        trackMouseDown?: boolean;
        trackMouseEnterExit?: boolean;
        trackMouseMove?: boolean;
        trackMouseUp?: boolean;
        trackRightMouseDown?: boolean;
        trackRightMouseUp?: boolean;
        transformation?: {
            m11?: number;
            m12?: number;
            m21?: number;
            m22?: number;
            tX?: number;
            tY?: number;
        };
        type: | "rectangle"
        | "circle"
        | "oval"
        | "arc"
        | "ellipticalArc"
        | "segments"
        | "points"
        | "text"
        | "image"
        | "canvas"
        | "resetClip";
        windingRule?: "nonZero"
        | "evenOdd";
    }
    Index
    action?: "fill" | "stroke" | "strokeAndFill" | "build" | "clip" | "skip"

    How the element's shape is drawn. Defaults to "strokeAndFill"

    arcClockwise?: boolean

    Draw an arc or ellipticalArc clockwise. Defaults to false

    arcRadii?: boolean

    Also draw the lines from an arc's centre to its ends. Defaults to false

    canvas?: HSCanvas

    The canvas a canvas element draws

    canvasAlpha?: number

    The nested canvas's opacity. Defaults to 1

    center?: { x?: string | number; y?: string | number }

    The centre of a circle or arc. Defaults to the centre of the canvas

    closed?: boolean

    Join the last point of a segments element back to its first. Defaults to false

    compositeRule?: string

    A blend mode for this element only, one of the names in hs.canvas.compositeTypes

    coordinates?: {
        c1x?: string | number;
        c1y?: string | number;
        c2x?: string | number;
        c2y?: string | number;
        x?: string | number;
        y?: string | number;
    }[]

    The points of a segments or points element. c1x/c1y/c2x/c2y curve a segment into its point

    endAngle?: number

    Where an arc or ellipticalArc ends, in degrees. Defaults to 360

    fillColor?: string | HSColor | HSCanvasColor

    The colour to fill the shape with

    fillGradient?: "linear" | "radial"

    Fill with a gradient instead of fillColor

    fillGradientAngle?: number

    The angle of a linear gradient, in degrees. Defaults to 0

    fillGradientCenter?: { x?: string | number; y?: string | number }

    The centre of a radial gradient. Defaults to the centre of the shape's bounds

    fillGradientColors?: (string | HSColor | HSCanvasColor)[]

    The gradient's colours, at least two, evenly spaced

    frame?: {
        h?: string | number;
        w?: string | number;
        x?: string | number;
        y?: string | number;
    }

    The bounds of a rectangle, oval, ellipticalArc, text, image or canvas. Defaults to the whole canvas; a missing x or y is 0, and a missing w or h is the canvas's

    id?: any

    Your own value for the element, passed back to mouse callbacks

    image?: HSImage

    The image of an image element

    imageAlignment?:
        | "left"
        | "right"
        | "center"
        | "top"
        | "bottom"
        | "topLeft"
        | "topRight"
        | "bottomLeft"
        | "bottomRight"

    Where the image sits in its frame. Defaults to "center"

    imageAlpha?: number

    The image's opacity. Defaults to 1

    imageScaling?: "none" | "scaleToFit" | "scaleProportionally" | "shrinkToFit"

    How the image is scaled to its frame. Defaults to "scaleProportionally"

    radius?: string | number

    The radius of a circle or arc. Defaults to half the canvas's shorter side

    reversePath?: boolean

    Reverse the direction of a circle's path, to cut a hole with build and clip

    rotation?: number

    Degrees to rotate the element by, about rotationPoint

    rotationPoint?: { x?: string | number; y?: string | number }

    The point to rotate about. Defaults to the centre of the element's bounds

    roundedRectRadii?: number | { xRadius?: number; yRadius?: number }

    The corner radius of a rectangle

    startAngle?: number

    Where an arc or ellipticalArc starts, in degrees. Defaults to 0

    strokeColor?: string | HSColor | HSCanvasColor

    The colour to outline the shape with

    strokeWidth?: number

    The width of the shape's outline

    text?: string

    The text of a text element

    textAlignment?: "left" | "right" | "center" | "justified" | "natural"

    How the text is aligned. Defaults to "natural"

    textColor?: string | HSColor | HSCanvasColor

    The text's colour. Defaults to black

    textDesign?: "monospaced" | "rounded" | "serif"

    The design of the system font, if textFont isn't set

    textFont?: string

    The PostScript name of the text's font, e.g. "Menlo-Bold"

    textItalic?: boolean

    Whether the text is italic

    textLineBreak?:
        | "clip"
        | "wordWrap"
        | "charWrap"
        | "truncateHead"
        | "truncateMiddle"
        | "truncateTail"

    How text that doesn't fit is wrapped or cut. Defaults to "wordWrap"

    textSize?: number

    The text's font size. Defaults to 27

    textWeight?:
        | "bold"
        | "medium"
        | "thin"
        | "ultraLight"
        | "light"
        | "regular"
        | "semibold"
        | "heavy"
        | "black"

    The text's weight, if textFont isn't set

    trackMouseDown?: boolean

    Report left mouse button presses on the element to the mouse callback

    trackMouseEnterExit?: boolean

    Report the mouse entering and leaving the element to the mouse callback

    trackMouseMove?: boolean

    Report the mouse moving over the element to the mouse callback

    trackMouseUp?: boolean

    Report left mouse button releases on the element to the mouse callback

    trackRightMouseDown?: boolean

    Report right mouse button presses on the element to the mouse callback

    trackRightMouseUp?: boolean

    Report right mouse button releases on the element to the mouse callback

    transformation?: {
        m11?: number;
        m12?: number;
        m21?: number;
        m22?: number;
        tX?: number;
        tY?: number;
    }

    An affine transformation matrix, used instead of rotation. Missing entries are the identity matrix's

    type:
        | "rectangle"
        | "circle"
        | "oval"
        | "arc"
        | "ellipticalArc"
        | "segments"
        | "points"
        | "text"
        | "image"
        | "canvas"
        | "resetClip"

    The kind of element

    windingRule?: "nonZero" | "evenOdd"

    How overlapping parts of a built-up path are filled. Defaults to "nonZero"