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.
62 lines
1.4 KiB
Java
62 lines
1.4 KiB
Java
import processing.core.PApplet;
|
|
|
|
import java.util.ArrayDeque;
|
|
|
|
class ProjectorApplet extends PApplet {
|
|
final int projectorScreenNumber = 2;
|
|
|
|
final static int centerX = 860;
|
|
final static int centerY = 540;
|
|
|
|
EuglenaApplet parent;
|
|
Calibrator calibrator;
|
|
|
|
ArrayDeque<ProjectorCommand> commandQueue;
|
|
|
|
ProjectorApplet(EuglenaApplet parent) {
|
|
this.parent = parent;
|
|
calibrator = new Calibrator(this);
|
|
commandQueue = new ArrayDeque<>();
|
|
}
|
|
|
|
public void settings() {
|
|
fullScreen(P2D, this.projectorScreenNumber);
|
|
}
|
|
|
|
@Override
|
|
public void setup() {
|
|
clear();
|
|
// calibrator.activate(); //for testing
|
|
}
|
|
|
|
@Override
|
|
public void draw() {
|
|
calibrator.draw(parent);
|
|
|
|
while (!commandQueue.isEmpty()) {
|
|
ProjectorCommand command = commandQueue.getFirst();
|
|
if (command.run(this)) {
|
|
commandQueue.removeFirst();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public float convertXCoord(float x) {
|
|
return (x / calibrator.magx + width * calibrator.offsetx);
|
|
}
|
|
|
|
public float convertYCoord(float y) {
|
|
return (y / calibrator.magy + height * calibrator.offsety);
|
|
}
|
|
|
|
public float convertXDistance(float dx) {
|
|
return (dx / calibrator.magx);
|
|
}
|
|
|
|
public float convertYDistance(float dy) {
|
|
return (dy / calibrator.magy);
|
|
}
|
|
}
|