Newer
Older
fractals / src / Polygon.ts
@peter peter on 2 Oct 2019 455 bytes Refactoring.
export class Point
{
    public x:number;
    public y:number;
    constructor(x:number, y:number)
    {
        this.x = x;
        this.y = y;
    }
}

export class Polygon extends Array<Point>
{
    public translate(x:number, y:number): Polygon
    {
        const newCorners = new Polygon();

        for(const corner of this)
        {
            newCorners.push(new Point(corner.x + x, corner.y + y));
        }

        return newCorners;
    }
}