MAIDR JavaScript API
    Preparing search index...

    A monochrome pin buffer sized to a tactile display's graphic area.

    Every pin is a single bit — raised or lowered. There is no grey, so a renderer targeting this buffer works in outlines and solid fills rather than in shading, and any anti-aliasing it might want has nowhere to go.

    Coordinates are dot coordinates with the origin at the top-left pin, x increasing to the right and y increasing downward, matching the order the DotPad hardware itself scans its cells.

    Index

    Constructors

    • Creates an all-lowered raster.

      Parameters

      • width: number

        Number of pins across

      • height: number

        Number of pins down

      Returns DotRaster

    Properties

    width: number

    Number of pins across.

    height: number

    Number of pins down.

    Accessors

    • get raisedCount(): number

      Number of raised pins. Used to decide whether a frame is worth sending and to pick between outline and fill when a mark is too small for both.

      Returns number

    Methods

    • Raises or lowers a single pin. Coordinates outside the buffer are ignored, so callers may draw shapes that run off the edge without clipping first.

      Parameters

      • x: number

        Dot column

      • y: number

        Dot row

      • on: boolean = true

        True to raise the pin, false to lower it

      Returns void

    • Reads a single pin. Coordinates outside the buffer read as lowered.

      Parameters

      • x: number

        Dot column

      • y: number

        Dot row

      Returns boolean

    • Draws a horizontal run of pins.

      Parameters

      • x0: number

        Starting dot column (inclusive)

      • x1: number

        Ending dot column (inclusive)

      • y: number

        Dot row

      • on: boolean = true

        True to raise, false to lower

      Returns void

    • Draws a vertical run of pins.

      Parameters

      • x: number

        Dot column

      • y0: number

        Starting dot row (inclusive)

      • y1: number

        Ending dot row (inclusive)

      • on: boolean = true

        True to raise, false to lower

      Returns void

    • Draws a straight line between two points using Bresenham's algorithm, one pin thick.

      Parameters

      • x0: number

        Start dot column

      • y0: number

        Start dot row

      • x1: number

        End dot column

      • y1: number

        End dot row

      • on: boolean = true

        True to raise, false to lower

      Returns void

    • Connects a run of points with straight segments.

      Parameters

      • points: readonly { x: number; y: number }[]

        Points in dot coordinates

      • on: boolean = true

        True to raise, false to lower

      Returns void

    • Connects a run of points with a stroke several pins wide.

      A one-pin stroke is at the floor of what a fingertip resolves, and a diagonal one is below it: Bresenham steps a shallow diagonal in single pins that touch only at their corners, so a finger sweeping across meets a row of separate bumps rather than a line, and loses the trail whenever it drifts by a pin. Widening the stroke is what turns a run of bumps into something that can be followed.

      Drawn as repeated offset passes rather than as a thick-line primitive: the grid is binary, so a union of one-pin strokes is exactly a wide stroke, and it costs a few passes over an area the size of a postcard.

      The offsets are perpendicular to each segment, and only perpendicular. An earlier version offset along both axes at once, on the reasoning that a path may run in any direction and the pass that does not thicken it costs nothing. It costs the width: offsetting a diagonal by a pin in x and again in y lands on four distinct columns per row, so a stroke asked for at two pins arrived at four. A line chart came back as a band a fingertip could not find an edge of, which is most of what a line is for.

      Parameters

      • points: readonly { x: number; y: number }[]

        Points in dot coordinates

      • weight: number

        Pins across the stroke; 1 draws a plain polyline

      • on: boolean = true

        True to raise, false to lower

      Returns void

    • Fills the interior of one or more closed rings using the even-odd rule.

      Rings are filled together rather than one at a time so a shape with a hole — a donut wedge, a glyph counter — keeps its hole instead of having it painted over by a later ring.

      Parameters

      • rings: readonly (readonly { x: number; y: number }[])[]

        Closed rings in dot coordinates; each is an implicitly closed sequence of points

      • on: boolean = true

        True to raise, false to lower

      Returns void

    • Fills rings with a texture whose crowding stands for a value.

      The pin grid has two states, so a value a chart drew as a colour has nowhere else to go. Density is the substitute a hand can read: a heatmap cell, a choropleth region, a hexbin cell and a mosaic tile are all the same size and shape as their neighbours, so without this the display carries their lattice and none of their numbers.

      Parameters

      • rings: readonly (readonly { x: number; y: number }[])[]

        Closed rings in dot coordinates

      • density: number

        How much of the interior to raise, 0 to 1

      Returns void

    • Raises a filled disc.

      For a mark with no interior of its own — a scatter point, a line's vertex — where the focus has to read as a separate object rather than as a thickening of the stroke it sits on.

      Parameters

      • cx: number

        Centre, in dot coordinates

      • cy: number

        Centre, in dot coordinates

      • radius: number

        Radius in pins

      Returns void

    • Reports whether two rasters hold identical pin states. Used to skip a transmission when a navigation move did not change the picture.

      Parameters

      • other: DotRaster

        The raster to compare against

      Returns boolean

    • Renders the buffer as text, one character per pin, for tests and debugging.

      Parameters

      • raised: string = 'O'

        Character for a raised pin

      • lowered: string = '.'

        Character for a lowered pin

      Returns string