blaze-2d
Version:
A fast and simple WebGL 2 2D game engine written in TypeScript
66 lines (65 loc) • 1.9 kB
TypeScript
import { vec2 } from "gl-matrix";
import Rect from "./rect";
/**
* Represents a line in 2D space.
*
* Can have textures and varying line thickness as a {@link Line} is really just a wrapper around {@link Rect}.
*
* Using `setWidth`, `setHeight`, `setRotation` or `setPosition` on a {@link Line} may lead to unexpected behaviour.
*/
export default class Line extends Rect {
private start;
private end;
private weight;
/**
* Create a {@link Line} with a start and end point.
*
* All values are in world space, including weight.
*
* @param start The start point of the line
* @param end The end point of the line
* @param weight The weight of the line's stroke (thickness)
*/
constructor(start: vec2, end: vec2, weight: number);
constructor(start: vec2, direction: vec2, length: number, weight: number);
constructor(start: vec2, angle: number, length: number, weight: number);
private createFromStartEnd;
private createFromDirection;
private createFromAngle;
/**
* Sets the weight of the line (thickness).
*
* @param weight The new weight of the line
*/
setWeight(weight: number): void;
/**
* Gets the weight of the line (thickness).
*
* @returns The stroke weight of the line
*/
getWeight(): number;
/**
* Sets the starting point of the line.
*
* @param start The new starting point of the line
*/
setStart(start: vec2): void;
/**
* Gets the point at which the line begins.
*
* @returns The start point of the line
*/
getStart(): vec2;
/**
* Sets the end point of the line.
*
* @param end The new end point of the line
*/
setEnd(end: vec2): void;
/**
* Gets the point at which the line ends.
*
* @returns The end point of the line
*/
getEnd(): vec2;
}