change coords

master
vitrinekast 9 months ago
parent c26057019f
commit 55bbf32e68

@ -70,7 +70,7 @@ const parseMessage = (message) => {
} else { } else {
switch (message.toLowerCase()) { switch (message.toLowerCase()) {
case 'init': case 'init':
toPlotter(translate()); toPlotter(init());
break; break;
case 'pu': case 'pu':
toPlotter(`PU;`); toPlotter(`PU;`);
@ -79,7 +79,7 @@ const parseMessage = (message) => {
toPlotter(`PD;`); toPlotter(`PD;`);
break; break;
case 'up': case 'up':
toPlotter(translate(distance * -1, 0)); toPlotter(translate(0, distance * -1));
break; break;
case 'down': case 'down':
toPlotter(translate(0, distance)); toPlotter(translate(0, distance));
@ -88,10 +88,7 @@ const parseMessage = (message) => {
toPlotter(translate(distance * -1, 0)); toPlotter(translate(distance * -1, 0));
break; break;
case 'right': case 'right':
toPlotter(translate(0, distance)); toPlotter(translate(distance, 0));
break;
case 'right':
toPlotter(translate(0, distance));
break; break;
case 'rectangle': case 'rectangle':
toPlotter(rectangle(distance)); toPlotter(rectangle(distance));

@ -10,12 +10,15 @@ function init(width = 4000, height = 4000) {
} }
function translate(x = 0, y = 0) { function translate(x = 0, y = 0) {
console.log(`translate: ${x} ${y}`);
state.position.x += x; state.position.x += x;
state.position.y += y; state.position.y += y;
console.log(`translate: ${state.position.x}`);
clampPosition(); clampPosition();
return `PR${state.position.x},${state.position.y};` return `PA${state.position.x},${state.position.y};`
} }
function to(x = 0, y = 0) { function to(x = 0, y = 0) {

Loading…
Cancel
Save