Skip to content

Commit 7b6a253

Browse files
committed
move PlotterCanvas to app file
1 parent c8748fe commit 7b6a253

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

app/PlotterCanvas.pde

-26
This file was deleted.

app/app.pde

+34-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void draw() {
9898
translate(plotXPx, plotYPx);
9999
imgSaver.startSave();
100100
strokeWeight(strokeWeight);
101-
101+
102102
stroke(0);
103103
noFill();
104104
sketch.draw();
@@ -618,4 +618,37 @@ class Field {
618618
boolean mouseIsOver() {
619619
return mouseX > x && mouseX < x + 50 && mouseY > y && mouseY < y + 20;
620620
}
621+
}
622+
623+
// ----------------------------------------
624+
// PLOTTER CANVAS
625+
// ----------------------------------------
626+
627+
// Sketch extends this
628+
// I only did this to hide the boilerplate from the Sketch file
629+
class PlotterCanvas {
630+
int w; // width in pixels
631+
int h; // height in pixels
632+
float ppi; // pixels per inch of printed doc
633+
float strokeWeight; // the scaled stroke weight for the sketch
634+
float screenScale; // the scale factor for the canvas
635+
636+
PlotterCanvas() {}
637+
638+
// this gets called whenever the canvas size changes
639+
// you can override it in Sketch, but make sure to call super
640+
void setDimensions(int _w, int _h, float _screenScale, float _ppi, float _strokeWeight) {
641+
w = _w;
642+
h = _h;
643+
screenScale = _screenScale;
644+
ppi = _ppi;
645+
strokeWeight = _strokeWeight;
646+
}
647+
648+
// these all get overridden in the Sketch
649+
void draw() {}
650+
void mousePressed() {}
651+
void mouseReleased() {}
652+
void keyPressed() {}
653+
void keyReleased() {}
621654
}

0 commit comments

Comments
 (0)