export class Repeats {
    constructor(session) {
        this.session = session;
    }
    /*
    * Repeat a drawing a specified number of times
    *
    * @param {Number} repeats
    * @param {Number} rotation
    * @param {Number} movement
    * @return void
    */
    repeatDrawing(repeats, rotation, movementX, movementY, callback) {
        const previousX = this.session.pos.x;
        const previousY = this.session.pos.y;
        const moveX = movementX ? movementX : 0;
        const moveY = movementY ? movementY : 0;
        // moves drawing context to centre around rotation point
        this.session.ctx.translate(previousX, previousY);
        this.session.ctx.moveTo(0, 0);
        for (var i = 0; i < repeats; i++) {
            this.session.pos = { x: 0 + moveX * i, y: 0 + moveY * i };
            callback();
            this.session.ctx.rotate(rotation * Math.PI / 180);
        }
        // resets changes
        const totalRotation = repeats * rotation * Math.PI / 180;
        this.session.ctx.rotate(-totalRotation);
        this.session.ctx.translate(-previousX, -previousY);
        this.session.pos.x = previousX;
        this.session.pos.y = previousY;
    }
    ;
}
export default Repeats;
//# sourceMappingURL=repeats.js.map