Initial commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
const setupScriptRunner = () => {
|
||||
canvasContext = canvas.getContext("2d");
|
||||
Painter.canvas = canvas;
|
||||
Painter.canvasContext = canvasContext;
|
||||
}
|
||||
|
||||
const runScript = () => {
|
||||
setToCenter();
|
||||
resetRotation();
|
||||
clearCanvas();
|
||||
|
||||
for (const elm of script.children) {
|
||||
elm.action(Painter);
|
||||
}
|
||||
}
|
||||
|
||||
const setToCenter = () => {
|
||||
Painter.x1 = Painter.canvas.width / 2
|
||||
Painter.y1 = Painter.canvas.height / 2
|
||||
Painter.canvasContext.moveTo( Painter.x1, Painter.y1 );
|
||||
}
|
||||
|
||||
const clearCanvas = () => {
|
||||
Painter.canvasContext.clearRect(0, 0, canvas.width, canvas.height);
|
||||
}
|
||||
|
||||
const resetRotation = () => {
|
||||
Painter.rotation = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user