diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 1baa905..f86c4f8 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -26,7 +26,6 @@
-
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0083fae..75e81d8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,10 +1,19 @@
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -28,8 +37,8 @@
-
-
+
+
@@ -48,11 +57,11 @@
-
+
-
-
+
+
@@ -67,30 +76,37 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
-
+
@@ -105,8 +121,8 @@
-
-
+
+
@@ -141,7 +157,6 @@
-
@@ -149,13 +164,18 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -193,7 +213,7 @@
-
+
@@ -536,8 +556,14 @@
-
-
+
+
+
+
+
+
+
+
@@ -578,7 +604,7 @@
-
+
@@ -749,22 +775,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -799,25 +809,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -826,58 +817,94 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
@@ -892,6 +919,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Calibrator.java b/src/Calibrator.java
index 7f08dcd..c3d4d39 100644
--- a/src/Calibrator.java
+++ b/src/Calibrator.java
@@ -107,6 +107,8 @@ class Calibrator {
projector.text("world!", x0+20, y0+110);
// Four dots used for calibration (may need to change code so that it better matches the math used to convert other points)
+ projector.ellipseMode(CORNER);
+
projector.fill(projector.color(0, 0, 190));
projector.ellipse(x0, y0, 5, 5);
diff --git a/src/Ellipse.java b/src/Ellipse.java
index b9ae67d..b19a6ca 100644
--- a/src/Ellipse.java
+++ b/src/Ellipse.java
@@ -13,6 +13,7 @@ class Ellipse {
Ellipse(int color, int penWidth) {
this.color = color;
this.brushSize = penWidth;
+ this.visible = false;
this.centerPointComplete = false;
this.widthComplete = false;
diff --git a/src/EuglenaApplet.java b/src/EuglenaApplet.java
index c66ffb4..f072f61 100644
--- a/src/EuglenaApplet.java
+++ b/src/EuglenaApplet.java
@@ -116,5 +116,27 @@ public class EuglenaApplet extends PApplet {
line(len, 0, len - 8, 8);
popMatrix();
}
+
+ void reset() {
+ if (projectorApplet.calibrator.active) {
+ projectorApplet.calibrator.deactivate();
+ } else {
+ projectorApplet.calibrator.deactivate();
+ ledControl.allOff();
+
+ projectorApplet.clear();
+
+// lines.clear();
+// ellipses.clear();
+// rectangles.clear();
+// triangles.clear();
+
+// shrinkwindows.clear();
+// expandwindows.clear();
+// translatewindows.clear();
+// rotatewindows.clear();
+
+ }
+ }
}
diff --git a/src/Line.java b/src/Line.java
new file mode 100644
index 0000000..665ef6d
--- /dev/null
+++ b/src/Line.java
@@ -0,0 +1,74 @@
+import processing.core.*;
+import static processing.core.PApplet.*;
+
+
+class Line {
+ float x1, y1, x2, y2;
+ int color, brushSize;
+ boolean visible;
+
+ private boolean point1complete;
+
+ Line(int color, int penWidth) {
+ this.color = color;
+ this.brushSize = penWidth;
+ this.visible = true;
+
+ this.point1complete = false;
+ }
+
+ Line(float x1, float y1, float x2, float y2, int color, int penWidth) {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ this.color = color;
+ this.brushSize = penWidth;
+ this.visible = true;
+
+ this.point1complete = true;
+ }
+
+
+ ProjectorCommand drawCommand() {
+ return (ProjectorApplet p) -> {
+ if (!visible) {
+ //done drawing already
+ return true;
+ }
+
+ float old_strokeWeight = p.g.strokeWeight;
+ int old_strokeColor = p.g.strokeColor;
+
+ p.strokeWeight(brushSize);
+ p.stroke(color);
+ p.noFill();
+
+ p.line(p.convertXCoord(x1), p.convertYCoord(y1),
+ p.convertXCoord(x2), p.convertYCoord(y2));
+
+ p.strokeWeight(old_strokeWeight);
+ p.stroke(old_strokeColor);
+ return true;
+ };
+ }
+
+ ClickGetter makeClickGetter(ProjectorApplet p) {
+ return (int x, int y) -> {
+ if (!point1complete){
+ x1 = x;
+ y1 = y;
+ point1complete = true;
+ return false;
+
+ } else {
+ x2 = x;
+ y2 = y;
+ visible = true;
+
+ p.commandQueue.add(drawCommand());
+ return true;
+ }
+ };
+ }
+}
diff --git a/src/LineClass.java b/src/LineClass.java
deleted file mode 100644
index 1e3cbe3..0000000
--- a/src/LineClass.java
+++ /dev/null
@@ -1,79 +0,0 @@
-class LineDrawer {
-
- Line lineinprogress;
-
- boolean point1complete;
-
- void reset() {
- lineinprogress = new Line(-1,-1,-1,-1);
- lineinprogress.visible = false;
- point1complete = false;
- }
-
- LineDrawer(){
- this.reset();
- }
-
- void mouseClicked(float x, float y){
- if (!point1complete){
- lineinprogress.x1 = x;
- lineinprogress.y1 = y;
- point1complete = true;
- } else {
- lineinprogress.x2 = x;
- lineinprogress.y2 = y;
- lineinprogress.visible = true;
- lines.add(lineinprogress);
-
- lineinprogress.draw();
- this.reset();
- }
- }
-}
-
-class Line {
-
- float x1, y1, x2, y2;
- int red, green, blue, brushSize;
- boolean visible;
-
- Line(float x1, float y1, float x2, float y2) {
- this.x1 = x1;
- this.y1 = y1;
- this.x2 = x2;
- this.y2 = y2;
- this.red = rVal;
- this.green = gVal;
- this.blue = bVal;
- this.brushSize = penWidth;
- this.visible = true;
- }
-
- void draw() {
- if (visible) {
- float old_strokeWeight = g.strokeWeight;
- int old_strokeColor = g.strokeColor;
- strokeWeight(brushSize);
- stroke(color(red, green, blue));
- line(convertXCoord(x1), convertYCoord(y1), convertXCoord(x2), convertYCoord(y2));
- strokeWeight(old_strokeWeight);
- stroke(old_strokeColor);
-
- print(rVal);
- print(",");
- print(gVal);
- print(",");
- print(bVal);
- print("\n");
-
- print(red);
- print(",");
- print(green);
- print(",");
- print(blue);
- print("\n");
- }
- }
-}
-
-
diff --git a/src/Menu.java b/src/Menu.java
index e6e515f..4fff1d3 100644
--- a/src/Menu.java
+++ b/src/Menu.java
@@ -189,6 +189,9 @@ class Menu {
}
void controlEvent(ControlEvent theEvent) {
+ println(theEvent);
+ println(theEvent.getName());
+ println(theEvent.getLabel());
if (theEvent.isFrom(shapesList)) {
switch((int) shapesList.getValue()) {
case 0:
@@ -196,117 +199,67 @@ class Menu {
.makeClickGetter(parent.projectorApplet);
break;
case 1:
- //rectangleDrawer.reset();
+ parent.clickGetter = new Rectangle(parent.penColor, parent.penWidth)
+ .makeClickGetter(parent.projectorApplet);
break;
case 2:
- //triangleDrawer.reset();
+ parent.clickGetter = new Triangle(parent.penColor, parent.penWidth)
+ .makeClickGetter(parent.projectorApplet);
break;
}
- }
-/*
- if (theEvent.isFrom(animateList)){
+ } else if (theEvent.isFrom(animateList)){
switch((int) animateList.getValue()) {
case 0:
- shrink.reset();
- drawtype = 's';
+// shrink.reset();
+// drawtype = 's';
break;
case 1:
- expand.reset();
- drawtype = 'x';
+// expand.reset();
+// drawtype = 'x';
break;
case 2:
- translate.reset();
- drawtype = 'm';
+// translate.reset();
+// drawtype = 'm';
break;
case 3:
- rotate.reset();
- drawtype = 'c';
+// rotate.reset();
+// drawtype = 'c';
+ break;
+ }
+ } else if (theEvent.isFrom(presetsList)){
+// preset = (int) presetsList.getValue();
+ } else {
+ switch (theEvent.getLabel()) {
+ case "Commit":
+ int rVal = Integer.parseInt(redField.getText());
+ int gVal = Integer.parseInt(greenField.getText());
+ int bVal = Integer.parseInt(blueField.getText());
+ parent.penColor = parent.color(rVal, gVal, bVal);
+
+ parent.penWidth = Integer.parseInt(penwidthField.getText());
+ parent.projectorApplet.setBgColor(Integer.parseInt(backgroundField.getText()));
+// parent.lagTime = Integer.parseInt(lagField.getText());
+// parent.totalTime = Integer.parseInt(totaltimeField.getText());
+// parent.speed = Integer.parseInt(speedField.getText());
+ break;
+
+ case "Reset":
+ parent.reset();
+ break;
+
+ case "Calibrate":
+ parent.projectorApplet.calibrator.toggle();
+ break;
+
+ case "Eraser":
+ parent.penColor = parent.color(0, 0, 0);
+ break;
+
+ case "Line":
+ parent.clickGetter = new Line(parent.penColor, parent.penWidth)
+ .makeClickGetter(parent.projectorApplet);
break;
}
}
-
- if (theEvent.isFrom(presetsList)){
- preset = (int) presetsList.getValue();
- }
- */
}
}
-
- /*
-
-
-*/
-/* Adds all features to initial display including toolbar and camera display */
-
-
-/*
-
-void Commit() {
- rVal = int(menu.redField.getText());
- gVal = int(menu.greenField.getText());
- bVal = int(menu.blueField.getText());
- penWidth = int(menu.penwidthField.getText());
- bgVal = int(menu.backgroundField.getText());
- lagTime = float(menu.lagField.getText());
- totalTime = int(menu.totaltimeField.getText());
- speed = int(menu.speedField.getText());
-
-// print(rVal);
-// print(",");
-// print(gVal);
-// print(",");
-// print(bVal);
-// print("\n");
-// print(speed);
-// print("\n");
-}
-
-
-void Reset() {
-
-
- if (calibrator.active = true){
- calibrator.toggle();
- } else {
- calibrator.active = false;
-
- clearDisplay();
-
- lines.clear();
- ellipses.clear();
- rectangles.clear();
- triangles.clear();
-
- shrinkwindows.clear();
- expandwindows.clear();
- translatewindows.clear();
- rotatewindows.clear();
-
- arduino.digitalWrite(left, Arduino.LOW);
- arduino.digitalWrite(right, Arduino.LOW);
- arduino.digitalWrite(up, Arduino.LOW);
- arduino.digitalWrite(down, Arduino.LOW);
-
- t = 0;
- t2 = 0;
- t3 = 0;
- t_temp = 0;
- }
-}
-
-void Calibrate() {
- frame.setLocation(0,0);
- calibrator.toggle();
-}
-
-void Eraser() {
- rVal = 0;
- gVal = 0;
- bVal = 0;
-}
-
-void Line() {
- lineDrawer.reset();
- drawtype = 'l';
-}
-*/
\ No newline at end of file
diff --git a/src/Procedure.java b/src/Procedure.java
deleted file mode 100644
index 777b914..0000000
--- a/src/Procedure.java
+++ /dev/null
@@ -1,4 +0,0 @@
-
-public interface Procedure {
- void execute();
-}
diff --git a/src/ProjectorApplet.java b/src/ProjectorApplet.java
index ba4722d..4b151d8 100644
--- a/src/ProjectorApplet.java
+++ b/src/ProjectorApplet.java
@@ -8,6 +8,8 @@ class ProjectorApplet extends PApplet {
final static int centerX = 860;
final static int centerY = 540;
+ int bgColor = color(0, 0, 0);
+
EuglenaApplet parent;
Calibrator calibrator;
@@ -26,6 +28,7 @@ class ProjectorApplet extends PApplet {
@Override
public void setup() {
clear();
+ smooth();
// calibrator.activate(); //for testing
}
@@ -43,6 +46,25 @@ class ProjectorApplet extends PApplet {
}
}
+ public void clear() {
+ fill(bgColor);
+ noStroke();
+ rectMode(CORNER);
+ rect(0, 0, width * 4, height * 4);
+ }
+
+ public void setBgColor(int c) {
+ bgColor = c;
+ }
+
+ public void setBgColor(int r, int b, int g) {
+ bgColor = color(r, g, b);
+ }
+
+ public int getBgColor() {
+ return bgColor;
+ }
+
public float convertXCoord(float x) {
return (x / calibrator.magx + width * calibrator.offsetx);
}
diff --git a/src/Rectangle.java b/src/Rectangle.java
new file mode 100644
index 0000000..c27b502
--- /dev/null
+++ b/src/Rectangle.java
@@ -0,0 +1,74 @@
+import processing.core.*;
+import static processing.core.PApplet.*;
+
+
+class Rectangle {
+
+ float corner1x, corner1y, corner2x, corner2y;
+ int color, brushSize;
+ boolean visible;
+
+ private boolean corner1complete;
+
+ Rectangle(int color, int penWidth) {
+ this.color = color;
+ this.brushSize = penWidth;
+ this.visible = false;
+
+ this.corner1complete = false;
+ }
+
+ Rectangle(float corner1x, float corner1y, float corner2x, float corner2y, int color, int penWidth) {
+ this.corner1x = corner1x;
+ this.corner1y = corner1y;
+ this.corner2x = corner2x;
+ this.corner2y = corner2y;
+ this.color = color;
+ this.brushSize = penWidth;
+ this.visible = true;
+
+ this.corner1complete = true;
+ }
+
+ ProjectorCommand drawCommand() {
+ return (ProjectorApplet p) -> {
+ if (!visible) {
+ //done drawing already
+ return true;
+ }
+
+ float old_strokeWeight = p.g.strokeWeight;
+ int old_strokeColor = p.g.strokeColor;
+
+ p.rectMode(CORNERS);
+ p.strokeWeight(brushSize);
+ p.stroke(color);
+ p.noFill();
+
+ p.rect(p.convertXCoord(corner1x), p.convertYCoord(corner1y),
+ p.convertXCoord(corner2x), p.convertYCoord(corner2y));
+
+ p.strokeWeight(old_strokeWeight);
+ p.stroke(old_strokeColor);
+ return true;
+ };
+ }
+
+ ClickGetter makeClickGetter(ProjectorApplet p) {
+ return (int x, int y) -> {
+ if (!corner1complete){
+ corner1x = x;
+ corner1y = y;
+ corner1complete = true;
+ return false;
+ } else {
+ corner2x = x;
+ corner2y = y;
+ visible = true;
+
+ p.commandQueue.add(drawCommand());
+ return true;
+ }
+ };
+ }
+}
diff --git a/src/RectangleClass.java b/src/RectangleClass.java
deleted file mode 100644
index 79f9b39..0000000
--- a/src/RectangleClass.java
+++ /dev/null
@@ -1,88 +0,0 @@
-//class RectangleDrawer {
-//
-// Rectangle rectangleinprogress;
-//
-// boolean corner1complete;
-//
-// void reset() {
-// rectangleinprogress = new Rectangle(-1,-1,0,0);
-// rectangleinprogress.visible = false;
-// corner1complete = false;
-//
-// }
-//
-// RectangleDrawer(){
-// this.reset();
-// }
-//
-// void mouseClicked(float x, float y){
-// if (!corner1complete){
-// rectangleinprogress.corner1x = x;
-// rectangleinprogress.corner1y = y;
-// corner1complete = true;
-//
-// } else {
-// rectangleinprogress.corner2x = x;
-// rectangleinprogress.corner2y = y;
-// rectangleinprogress.visible = true;
-// rectangles.add(rectangleinprogress);
-//
-// rectangleinprogress.draw();
-// this.reset();
-// }
-// }
-//}
-//
-//class Rectangle {
-//
-// float corner1x, corner1y, corner2x, corner2y;
-// int red, green, blue, brushSize;
-// boolean visible;
-//
-// Rectangle(float corner1x, float corner1y, float corner2x, float corner2y) {
-// this.corner1x = corner1x;
-// this.corner1y = corner1y;
-// this.corner2x = corner2x;
-// this.corner2y = corner2y;
-// this.red = rVal;
-// this.green = gVal;
-// this.blue = bVal;
-// this.brushSize = penWidth;
-// this.visible = true;
-// }
-//
-// void draw() {
-// if (visible) {
-// float old_strokeWeight = g.strokeWeight;
-// int old_strokeColor = g.strokeColor;
-//
-// rectMode(CORNERS);
-// strokeWeight(brushSize);
-// stroke(color(red, green, blue));
-// noFill();
-//
-// rect(convertXCoord(corner1x), convertYCoord(corner1y), convertXCoord(corner2x), convertYCoord(corner2y));
-// strokeWeight(old_strokeWeight);
-// stroke(old_strokeColor);
-//
-// print(rVal);
-// print(",");
-// print(gVal);
-// print(",");
-// print(bVal);
-// print("\n");
-//
-//
-// /*
-// print(convertXCoord(corner1x));
-// print("\n");
-// print(convertYCoord(corner1y));
-// print("\n");
-// print(convertXCoord(corner2x));
-// print("\n");
-// print(convertYCoord(corner2y));
-// print("\n");
-// */
-// }
-// }
-//}
diff --git a/src/Triangle.java b/src/Triangle.java
new file mode 100644
index 0000000..201958e
--- /dev/null
+++ b/src/Triangle.java
@@ -0,0 +1,86 @@
+import processing.core.*;
+import static processing.core.PApplet.*;
+
+
+class Triangle {
+ float point1x, point1y, point2x, point2y, point3x, point3y;
+ int color, brushSize;
+ boolean visible;
+
+ private boolean point1complete, point2complete;
+
+ Triangle(int color, int penWidth) {
+ this.color = color;
+ this.brushSize = penWidth;
+ this.visible = false;
+
+ this.point1complete = false;
+ this.point2complete = false;
+ }
+
+ Triangle(float point1x, float point1y, float point2x, float point2y,
+ float point3x, float point3y, int color, int penWidth) {
+ this.point1x = point1x;
+ this.point1y = point1y;
+ this.point2x = point2x;
+ this.point2y = point2y;
+ this.point3x = point3x;
+ this.point3y = point3y;
+
+ this.color = color;
+ this.brushSize = penWidth;
+ this.visible = true;
+
+ this.point1complete = true;
+ this.point2complete = true;
+ }
+
+ ProjectorCommand drawCommand() {
+ return (ProjectorApplet p) -> {
+ if (!visible) {
+ //done drawing already
+ return true;
+ }
+
+ float old_strokeWeight = p.g.strokeWeight;
+ int old_strokeColor = p.g.strokeColor;
+
+ p.strokeWeight(brushSize);
+ p.stroke(color);
+ p.noFill();
+
+ p.triangle(p.convertXCoord(point1x), p.convertYCoord(point1y),
+ p.convertXCoord(point2x), p.convertYCoord(point2y),
+ p.convertXCoord(point3x), p.convertYCoord(point3y));
+
+ p.strokeWeight(old_strokeWeight);
+ p.stroke(old_strokeColor);
+ return true;
+ };
+ }
+
+ ClickGetter makeClickGetter(ProjectorApplet p) {
+ return (int x, int y) -> {
+ if (!point1complete){
+ point1x = x;
+ point1y = y;
+ point1complete = true;
+ return false;
+
+ } else if (!point2complete) {
+ point2x = x;
+ point2y = y;
+ point2complete = true;
+ return false;
+
+ } else {
+ point3x = x;
+ point3y = y;
+ visible = true;
+
+ p.commandQueue.add(drawCommand());
+ return true;
+ }
+ };
+ }
+}
diff --git a/src/TriangleClass.java b/src/TriangleClass.java
deleted file mode 100644
index fadeeeb..0000000
--- a/src/TriangleClass.java
+++ /dev/null
@@ -1,98 +0,0 @@
-//class TriangleDrawer {
-//
-// Triangle triangleinprogress;
-//
-// boolean point1complete;
-// boolean point2complete;
-//
-// void reset() {
-// triangleinprogress = new Triangle(-1,-1,0,0,1,1);
-// triangleinprogress.visible = false;
-// point1complete = false;
-// point2complete = false;
-//
-// }
-//
-// TriangleDrawer(){
-// this.reset();
-// }
-//
-// void mouseClicked(float x, float y){
-// if (!point1complete){
-// triangleinprogress.point1x = x;
-// triangleinprogress.point1y = y;
-// point1complete = true;
-//
-// } else if (!point2complete) {
-// triangleinprogress.point2x = x;
-// triangleinprogress.point2y = y;
-// point2complete = true;
-//
-// } else {
-// triangleinprogress.point3x = x;
-// triangleinprogress.point3y = y;
-// triangleinprogress.visible = true;
-// triangles.add(triangleinprogress);
-//
-// triangleinprogress.draw();
-// this.reset();
-// }
-// }
-//}
-//
-//class Triangle {
-//
-// float point1x, point1y, point2x, point2y, point3x, point3y;
-// int red, green, blue, brushSize;
-// boolean visible;
-//
-// Triangle(float point1x, float point1y, float point2x, float point2y, float point3x, float point3y) {
-// this.point1x = point1x;
-// this.point1y = point1y;
-// this.point2x = point2x;
-// this.point2y = point2y;
-// this.point3x = point3x;
-// this.point3y = point3y;
-// this.red = rVal;
-// this.green = gVal;
-// this.blue = bVal;
-// this.brushSize = penWidth;
-// this.visible = true;
-// }
-//
-// void draw() {
-// if (visible) {
-// float old_strokeWeight = g.strokeWeight;
-// int old_strokeColor = g.strokeColor;
-//
-// strokeWeight(brushSize);
-// stroke(color(red, green, blue));
-// noFill();
-//
-// triangle(convertXCoord(point1x), convertYCoord(point1y), convertXCoord(point2x), convertYCoord(point2y),
-// convertXCoord(point3x), convertYCoord(point3y));
-// strokeWeight(old_strokeWeight);
-// stroke(old_strokeColor);
-//
-// /*
-// print(rVal);
-// print(",");
-// print(gVal);
-// print(",");
-// print(bVal);
-// print("\n");
-// */
-//
-// /*
-// print(convertXCoord(centerx));
-// print("\n");
-// print(convertYCoord(centery));
-// print("\n");
-// print(convertXDistance(width));
-// print("\n");
-// print(convertYDistance(height));
-// print("\n");
-// */
-// }
-// }
-//}
diff --git a/src/clearDisplay.java b/src/clearDisplay.java
deleted file mode 100644
index 966b94b..0000000
--- a/src/clearDisplay.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Draws a black rectangle the size of the second monitor
-completely covers whatever was beneath it so that it looks clear */
-void clearDisplay() {
- // second monitor
- fill(color(bgR, bgG, bgB));
- noStroke();
- rectMode(CORNER);
- rect(displayWidth,0,displayWidth*4,displayHeight-10);
-}
-
-
-