import { Palette } from './modules/palette.js';
import { Space } from './modules/space.js';
import { General } from './modules/general.js';
import { Paths } from './modules/paths.js';
import { Repeats } from './modules/repeats.js';
import { Setters } from './modules/setters.js';
import { Shapes } from './modules/shapes.js';
import { Stamp } from './modules/stamp.js';
import { Text } from './modules/text.js';
export class Canvas {
    constructor(settings) {
        this.palette = Palette;
        this.session = this.createSession(settings);
        this.general = new General(this.session);
        this.paths = new Paths(this.session);
        this.repeats = new Repeats(this.session);
        this.setters = new Setters(this.session);
        this.shapes = new Shapes(this.session);
        this.space = new Space(this.session);
        this.stamp = new Stamp(this.session);
        this.text = new Text(this.session);
        this.reset(settings);
    }
    createSession(settings) {
        return {
            ctx: settings.ctx,
            width: settings.width,
            height: settings.height,
            ratio: settings.ratio || 1,
            stickers: settings.stickers || {
                categorisedResource: [],
                categoryEnum: [],
                getUrl: () => { return ''; },
                getRandom: () => { return ''; },
                getRandomFrom: () => { return ''; }
            },
            pos: {
                x: settings.width / 2,
                y: settings.height / 2,
            },
            settings: {
                bg: null,
                fill: '#000000',
                text: {
                    align: 'start',
                    baseline: 'alphabetic',
                    bold: false,
                    italic: false,
                    font: 'Bariol',
                    size: 16,
                },
                stroke: {
                    color: '#000000',
                    cap: 'butt',
                    width: 1,
                },
            },
        };
    }
    reset(settings) {
        this.session.ctx = settings.ctx;
        this.session.width = settings.width;
        this.session.height = settings.height;
        this.session.ratio = settings.ratio || 1;
        this.session.pos = {
            x: settings.width / 2,
            y: settings.height / 2,
        };
        this.general.reset();
        this.space.moveTo(this.session.pos.x, this.session.pos.y);
        this.setters.strokeColor(this.session.settings.stroke.color);
        this.setters.strokeWidth(this.session.settings.stroke.width);
        this.paths.lineCap(this.session.settings.stroke.cap);
        this.text.updateFont();
        return this.session;
    }
}
export default Canvas;
//# sourceMappingURL=kano-canvas-api.js.map