You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.0 KiB
Java

import processing.core.*;
public class EuglenaApplet extends PApplet {
final int cameraMode = 9;
final int whichArduino = 0;
// Hardware
ProjectorApplet projectorApplet;
Camera camera;
LEDControl ledControl;
// Software components
Menu menu;
Calibrator calibrator;
ClickGetter clickGetter;
boolean tester;
public static void main(String args[]) {
PApplet.main("EuglenaApplet");
}
@Override
public void settings() {
size(1920, 1200, P2D);
}
@Override
public void setup() {
clear();
smooth();
camera = new Camera(this, cameraMode);
ledControl = new LEDControl(this, whichArduino);
menu = new Menu(this);
// Start up projectorApplet window
// Do this last, in case ProjectorApplet wants to use the camera, arduino, etc.
projectorApplet = new ProjectorApplet(this);
String[] args = {"Euglena projector"};
PApplet.runSketch(args, projectorApplet);
tester = false;
}
@Override
public void draw() {
menu.draw(this, ledControl);
//Update webcam and draw the updated image to the screen
camera.updateImage();
imageMode(PApplet.CORNER);
image(camera.getImage(), 0, 0, width - menu.width, height);
if (!tester) {
// this.projectorApplet.commandQueue.add(new Ellipse(0f, 0f, 1000f, 1000f, color(250, 250, 250), 8).drawCommand());
this.clickGetter = new Ellipse(color(255), 10).clickGetter(projectorApplet);
tester = true;
}
}
@Override
public void mouseClicked(){
if (clickGetter != null) {
if (clickGetter.click(mouseX, mouseY)) {
clickGetter = null;
}
}
}
void drawArrow(int cx, int cy, int len, float angle){
pushMatrix();
translate(cx, cy);
rotate(radians(angle));
line(0,0,len, 0);
line(len, 0, len - 8, -8);
line(len, 0, len - 8, 8);
popMatrix();
}
}