Ellipse can be drawn...
This commit is contained in:
parent
c27394c4a1
commit
ee6eccee36
10 changed files with 405 additions and 241 deletions
|
|
@ -2,6 +2,8 @@
|
|||
doodle button is pressed */
|
||||
|
||||
import processing.core.*;
|
||||
import static processing.core.PApplet.*;
|
||||
|
||||
|
||||
class Calibrator {
|
||||
|
||||
|
|
@ -52,16 +54,16 @@ class Calibrator {
|
|||
|
||||
// Calibration of projectorApplet field of view
|
||||
switch(keyCode) {
|
||||
case PApplet.UP:
|
||||
case UP:
|
||||
offsety = offsety - .001f; //Moves projections up in app view
|
||||
break;
|
||||
case PApplet.DOWN:
|
||||
case DOWN:
|
||||
offsety = offsety + .001f; //Moves projections down
|
||||
break;
|
||||
case PApplet.LEFT:
|
||||
case LEFT:
|
||||
offsetx = offsetx - .001f; // Moves projections left
|
||||
break;
|
||||
case PApplet.RIGHT:
|
||||
case RIGHT:
|
||||
offsetx = offsetx + .001f; // Moves projections right
|
||||
break;
|
||||
case 36:
|
||||
|
|
@ -76,9 +78,9 @@ class Calibrator {
|
|||
case 34:
|
||||
magy = magy - .05f; // PAGE DOWN button increases height of projections
|
||||
break;
|
||||
case PApplet.SHIFT:
|
||||
PApplet.println("x-offset: " + offsetx + " | y-offset: " + offsety);
|
||||
PApplet.println("x-magnification: " + magx + " | y-magnification: " + magy);
|
||||
case SHIFT:
|
||||
println("x-offset: " + offsetx + " | y-offset: " + offsety);
|
||||
println("x-magnification: " + magx + " | y-magnification: " + magy);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import processing.core.*;
|
||||
import processing.video.*;
|
||||
|
||||
import static processing.core.PApplet.*;
|
||||
|
||||
class Camera {
|
||||
Capture cam;
|
||||
|
|
@ -12,19 +12,19 @@ class Camera {
|
|||
Camera(PApplet applet, int cameraMode) {
|
||||
String[] cameras = Capture.list();
|
||||
if (cameras.length == 0) {
|
||||
PApplet.println("There are no cameras available for capture.");
|
||||
println("There are no cameras available for capture.");
|
||||
applet.exit();
|
||||
} else {
|
||||
PApplet.println("Available cameras:");
|
||||
println("Available cameras:");
|
||||
for(int i = 0; i < cameras.length; i++) {
|
||||
PApplet.println(i, cameras[i]);
|
||||
println(i, cameras[i]);
|
||||
}
|
||||
PApplet.print("Using camera mode ");
|
||||
PApplet.println(cameras[cameraMode]);
|
||||
print("Using camera mode ");
|
||||
println(cameras[cameraMode]);
|
||||
this.cam = new Capture(applet, cameras[cameraMode]);
|
||||
this.cam.start();
|
||||
|
||||
this.updateImage();
|
||||
latestImage = cam; //initialize unconditionally
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ import processing.core.*;
|
|||
//
|
||||
// void mouseClicked(ProjectorApplet p, float x, float y){
|
||||
// if (!centerpointcomplete){
|
||||
// ellipseinprogress.centerx = x;
|
||||
// ellipseinprogress.centery = y;
|
||||
// ellipseinprogress.centerX = x;
|
||||
// ellipseinprogress.centerY = y;
|
||||
// centerpointcomplete = true;
|
||||
//
|
||||
// } else if (!widthcomplete) {
|
||||
// ellipseinprogress.width = PApplet.abs(ellipseinprogress.centerx - x) * 2;
|
||||
// ellipseinprogress.width = PApplet.abs(ellipseinprogress.centerX - x) * 2;
|
||||
// widthcomplete = true;
|
||||
//
|
||||
// } else {
|
||||
// ellipseinprogress.height = PApplet.abs(ellipseinprogress.centery - y) * 2;
|
||||
// ellipseinprogress.height = PApplet.abs(ellipseinprogress.centerY - y) * 2;
|
||||
// ellipseinprogress.visible = true;
|
||||
// //ellipses.add(ellipseinprogress);
|
||||
//
|
||||
|
|
@ -42,13 +42,13 @@ import processing.core.*;
|
|||
|
||||
class Ellipse {
|
||||
|
||||
float centerx, centery, width, height;
|
||||
float centerX, centerY, width, height;
|
||||
int red, green, blue, brushSize;
|
||||
boolean visible;
|
||||
|
||||
Ellipse(float centerx, float centery, float width, float height, int rVal, int gVal, int bVal, int penWidth) {
|
||||
this.centerx = centerx;
|
||||
this.centery = centery;
|
||||
Ellipse(float centerX, float centerY, float width, float height, int rVal, int gVal, int bVal, int penWidth) {
|
||||
this.centerX = centerX;
|
||||
this.centerY = centerY;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.red = rVal;
|
||||
|
|
@ -58,40 +58,24 @@ class Ellipse {
|
|||
this.visible = true;
|
||||
}
|
||||
|
||||
void draw(ProjectorApplet p) {
|
||||
void draw(ProjectorApplet projector) {
|
||||
if (visible) {
|
||||
float old_strokeWeight = p.g.strokeWeight;
|
||||
int old_strokeColor = p.g.strokeColor;
|
||||
projector.commandQueue.add(
|
||||
(ProjectorApplet p) -> {
|
||||
float old_strokeWeight = p.g.strokeWeight;
|
||||
int old_strokeColor = p.g.strokeColor;
|
||||
|
||||
p.ellipseMode(PApplet.CENTER);
|
||||
p.strokeWeight(brushSize);
|
||||
p.stroke(p.color(red, green, blue));
|
||||
p.noFill();
|
||||
p.ellipseMode(PApplet.CENTER);
|
||||
p.strokeWeight(brushSize);
|
||||
p.stroke(p.color(red, green, blue));
|
||||
p.noFill();
|
||||
|
||||
p.ellipse(p.convertXCoord(centerx), p.convertYCoord(centery),
|
||||
p.convertXDistance(width), p.convertYDistance(height));
|
||||
p.strokeWeight(old_strokeWeight);
|
||||
p.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");
|
||||
*/
|
||||
p.ellipse(p.convertXCoord(centerX), p.convertYCoord(centerY),
|
||||
p.convertXDistance(width), p.convertYDistance(height));
|
||||
p.strokeWeight(old_strokeWeight);
|
||||
p.stroke(old_strokeColor);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import processing.core.*;
|
||||
|
||||
public class EuglenaApplet extends PApplet {
|
||||
final int cameraMode = 77;
|
||||
final int cameraMode = 9;
|
||||
final int whichArduino = 0;
|
||||
|
||||
// Hardware
|
||||
|
|
@ -13,6 +13,8 @@ public class EuglenaApplet extends PApplet {
|
|||
Menu menu;
|
||||
Calibrator calibrator;
|
||||
|
||||
boolean tester;
|
||||
|
||||
public static void main(String args[]) {
|
||||
PApplet.main("EuglenaApplet");
|
||||
}
|
||||
|
|
@ -37,6 +39,7 @@ public class EuglenaApplet extends PApplet {
|
|||
projectorApplet = new ProjectorApplet(this);
|
||||
String[] args = {"Euglena projector"};
|
||||
PApplet.runSketch(args, projectorApplet);
|
||||
tester = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -48,6 +51,10 @@ public class EuglenaApplet extends PApplet {
|
|||
imageMode(PApplet.CORNER);
|
||||
image(camera.getImage(), 0, 0, width - menu.width, height);
|
||||
|
||||
if (!tester) {
|
||||
new Ellipse(0f, 0f, 1000f, 1000f, 250, 250, 250, 8).draw(this.projectorApplet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import processing.core.*;
|
||||
import static processing.core.PApplet.*;
|
||||
import cc.arduino.*;
|
||||
|
||||
class LEDControl {
|
||||
|
|
@ -11,15 +12,15 @@ class LEDControl {
|
|||
// Arduino - initialize correct arduino
|
||||
String[] arduinos = Arduino.list();
|
||||
if (arduinos.length == 0) {
|
||||
PApplet.println("There are no arduinos available for use.");
|
||||
println("There are no arduinos available for use.");
|
||||
applet.exit();
|
||||
} else {
|
||||
PApplet.println("Available arduinos:");
|
||||
println("Available arduinos:");
|
||||
for( String ard : arduinos) {
|
||||
PApplet.println(ard);
|
||||
println(ard);
|
||||
}
|
||||
PApplet.print("Using arduino ");
|
||||
PApplet.println(arduinos[whichArduino]);
|
||||
print("Using arduino ");
|
||||
println(arduinos[whichArduino]);
|
||||
|
||||
// this.arduino = new Arduino(applet, arduinos[whichArduino], comRate);
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import processing.core.*;
|
||||
import org.firmata.*;
|
||||
import gab.opencv.*;
|
||||
import cc.arduino.*;
|
||||
import controlP5.*;
|
||||
|
||||
class Menu {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import processing.core.PApplet;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.function.*;
|
||||
|
||||
class ProjectorApplet extends PApplet {
|
||||
final int projectorScreenNumber = 2;
|
||||
|
|
@ -10,9 +12,12 @@ class ProjectorApplet extends PApplet {
|
|||
EuglenaApplet parent;
|
||||
Calibrator calibrator;
|
||||
|
||||
ArrayDeque<ProjectorCommand> commandQueue;
|
||||
|
||||
ProjectorApplet(EuglenaApplet parent) {
|
||||
this.parent = parent;
|
||||
calibrator = new Calibrator(this);
|
||||
commandQueue = new ArrayDeque<>();
|
||||
}
|
||||
|
||||
public void settings() {
|
||||
|
|
@ -22,16 +27,25 @@ class ProjectorApplet extends PApplet {
|
|||
@Override
|
||||
public void setup() {
|
||||
clear();
|
||||
calibrator.activate();
|
||||
// calibrator.activate(); //for testing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
background(50);
|
||||
fill(255);
|
||||
ellipse(mouseX, mouseY, 10, 10);
|
||||
// background(50);
|
||||
// fill(255);
|
||||
// ellipse(mouseX, mouseY, 10, 10);
|
||||
|
||||
calibrator.draw(parent);
|
||||
|
||||
while (!commandQueue.isEmpty()) {
|
||||
ProjectorCommand command = commandQueue.getFirst();
|
||||
if (command.run(this)) {
|
||||
commandQueue.removeFirst();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float convertXCoord(float x) {
|
||||
|
|
|
|||
3
src/ProjectorCommand.java
Normal file
3
src/ProjectorCommand.java
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
public interface ProjectorCommand {
|
||||
boolean run(ProjectorApplet p);
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// SlowConcentrate(int centerX, int centerY){
|
||||
//
|
||||
// this.centerX = centerX;
|
||||
// this.centerY = centery;
|
||||
// this.centerY = centerY;
|
||||
// this.speed = speedSet;
|
||||
// this.red = rVal;
|
||||
// this.green = gVal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue