Skip to content

Line

A Line draws a straight line between two points.

Example

Usage

ts
import {
    createLine,
} from '@ripl/core';

const line = createLine({
    strokeStyle: '#3a86ff',
    lineWidth: 2,
    x1: 50,
    y1: 50,
    x2: 250,
    y2: 200,
});

Properties

PropertyTypeRequiredDescription
x1numberYesStart X coordinate
y1numberYesStart Y coordinate
x2numberYesEnd X coordinate
y2numberYesEnd Y coordinate

Plus all Element style properties and Shape options.

TIP

Lines are stroked by default. Set strokeStyle to see the line — fillStyle alone won't produce a visible result.