figureone
    Preparing search index...

    Options object for a FigureElementPrimitive of a generic shape

    points will define either triangles or lines which combine to make the shape.

    drawType defines what sort of triangles or lines the points make. The most useful, common and generic drawType is 'TRIANGLES' which can be used to create any shape.

    The shape's points can be duplicated using the copy property to conveniently create multiple copies (like grids) of shapes.

    The shape is colored with either color or texture.

    When shapes move, or are touched, borders are needed to bound their movement, and figure out if a touch happened within the shape. Shapes that do not move, or are not interactive, do not need borders.

    A shape can have several kinds of borders. "Draw borders" (drawBorder and drawBorderBuffer) are sets of points that define reference borders for a shape. The shapes higher level borders border and touchBorder may then use these draw borders to define how a shape will interact with a figure's bounds, or where a shape can be touched.

    drawBorder and drawBorderBuffer are each point arrays that define the outer limits of the shape. For non-contigous shapes (like islands of shapes), an array of point arrays can be used. Both borders can be anything, but typically a drawBorder would define the border of the visible shape, and a drawBorderBuffer would define some extra space, or buffer, around the visible shape (particulaly useful for defining the touchBorder later).

    border is used for checking if the shape is within some bounds. When shapes are moved, if their bounds are limited, this border will define when the shape is at a limit. The border property can be:

    • draw: use drawBorder points
    • buffer: use drawBorderBuffer points
    • rect: use a rectangle bounding drawBorder
    • number: use a rectangle that is number larger than the rectangle bounding drawBorder
    • Array<TypeParsablePoint>: a custom contiguous border
    • Array<Array<TypeParsablePoint>>: a custom border of several contiguous portions

    touchBorder is used for checking if a shape is touched. The touchBorder property can be:

    • draw: use drawBorder points
    • buffer: use drawBorderBuffer points
    • border: use same as border
    • rect: use a rectangle bounding border
    • number: use a rectangle that is number larger than the rectangle bounding border
    • Array<TypeParsablePoint>: a custom contiguous border
    • Array<Array<TypeParsablePoint>>: a custom border of several contiguous portions

    To test examples, append them to the boilerplate

    // Square and triangle
    figure.add({
    name: 'squareAndTri',
    make: 'generic',
    points: [
    [-1, 0.5], [-1, -0.5], [0, 0.5],
    [0, 0.5], [-1, -0.5], [0, -0.5],
    [0, -0.5], [1, 0.5], [1, -0.5],
    ],
    });
    // rhombus with larger touch borders
    figure.add({
    name: 'rhombus',
    make: 'generic',
    points: [
    [-0.5, -0.5], [0, 0.5], [1, 0.5],
    [-0.5, -0.5], [1, 0.5], [0.5, -0.5],
    ],
    border: [[
    [-1, -1], [-0.5, 1], [1.5, 1], [1, -1],
    ]],
    mods: {
    isMovable: true,
    move: {
    bounds: 'figure',
    },
    },
    });
    // Grid of triangles
    figure.add({
    name: 'gridOfTris',
    make: 'generic',
    points: [
    [-1, -1], [-0.7, -1], [-1, -0.7],
    ],
    copy: [
    { along: 'x', num: 5, step: 0.4 },
    { along: 'y', num: 5, step: 0.4 },
    ],
    });
    @interface