in share/src/sprite-editor/spriteEditor.ts [101:180]
constructor(bitmap: Bitmap, blocksInfo?: {}, protected lightMode = false, public scale = 1) {
this.columns = bitmap.width;
this.rows = bitmap.height;
this.state = new CanvasState(bitmap.copy())
this.toolbarRoot = new svg.SVG();
this.toolbarRoot.setClass("sprite-canvas-controls");
this.group = this.toolbarRoot.group();
this.createDefs();
this.paintSurface = new CanvasGrid(COLORS, this.state.copy(), this.lightMode, this.scale);
this.paintSurface.drag((col, row) => {
this.debug("gesture (" + PaintTool[this.activeTool] + ")");
if (!this.altDown) {
this.setCell(col, row, this.color, false);
}
// this.bottomBar.updateCursor(col, row);
});
this.paintGestureInterval = setInterval(this.logEvents, 5000);
this.paintSurface.up((col, row) => {
this.debug("gesture end (" + PaintTool[this.activeTool] + ")");
this.paintGestureCount += 1;
if (this.altDown) {
const color = this.state.image.get(col, row);
this.sidebar.setColor(color);
} else {
this.paintSurface.onEditEnd(col, row, this.edit);
if (this.state.floatingLayer && !this.paintSurface.state.floatingLayer) {
this.pushState(true);
this.state = this.paintSurface.state.copy();
this.rePaint();
}
this.commit();
this.shiftAction();
}
this.mouseDown = false;
});
this.paintSurface.down((col, row) => {
if (!this.altDown) {
this.setCell(col, row, this.color, false);
}
this.mouseDown = true;
});
this.paintSurface.move((col, row) => {
this.drawCursor(col, row);
this.shiftAction()
// this.bottomBar.updateCursor(col, row);
});
this.paintSurface.leave(() => {
if (this.edit) {
this.rePaint();
if (this.edit.isStarted && !this.shiftDown) {
this.commit();
}
}
// this.bottomBar.hideCursor();
});
this.sidebar = new SideBar(['url("#alpha-background")'].concat(COLORS), this, this.group);
this.sidebar.setColor(COLORS.length >= 3 ? 3 : 1); // colors omits 0
// this.header = new SpriteHeader(this);
// this.gallery = new Gallery(blocksInfo);
// this.bottomBar = new ReporterBar(this.group, this, REPORTER_BAR_HEIGHT);
this.updateUndoRedo();
// Sets canvas scale
this.scale = scale;
}