animations work
This commit is contained in:
parent
19ca54add7
commit
cd714a0274
9 changed files with 170 additions and 285 deletions
|
|
@ -18,6 +18,7 @@ public class EuglenaApplet extends PApplet {
|
|||
//Pen
|
||||
int penColor = color(200);
|
||||
int penWidth = 15;
|
||||
int operationSpeed = 10; //speed for Shrink, Expand, etc.
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
|
@ -119,18 +120,7 @@ public class EuglenaApplet extends PApplet {
|
|||
projectorApplet.calibrator.deactivate();
|
||||
ledControl.allOff();
|
||||
|
||||
projectorApplet.clear();
|
||||
|
||||
// lines.clear();
|
||||
// ellipses.clear();
|
||||
// rectangles.clear();
|
||||
// triangles.clear();
|
||||
|
||||
// shrinkwindows.clear();
|
||||
// expandwindows.clear();
|
||||
// translatewindows.clear();
|
||||
// rotatewindows.clear();
|
||||
|
||||
projectorApplet.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import static processing.core.PApplet.*;
|
|||
public class Expand {
|
||||
float corner1x, corner1y, corner2x, corner2y, speed;
|
||||
int timeElapsed, millisInit;
|
||||
PImage expandRegion;
|
||||
PImage expandRegion = null;
|
||||
|
||||
private boolean corner1complete;
|
||||
|
||||
|
|
@ -48,6 +48,11 @@ public class Expand {
|
|||
|
||||
ProjectorCommand makeProjectorCommand() {
|
||||
return (ProjectorApplet p) -> {
|
||||
if (expandRegion == null) {
|
||||
millisInit = p.millis();
|
||||
saveExpandRegion(p);
|
||||
}
|
||||
|
||||
timeElapsed = p.millis() - millisInit;
|
||||
|
||||
float spaceElapsed = speed * (timeElapsed / 1000f);
|
||||
|
|
@ -85,8 +90,6 @@ public class Expand {
|
|||
} else {
|
||||
corner2x = x;
|
||||
corner2y = y;
|
||||
millisInit = p.millis();
|
||||
saveExpandRegion(p);
|
||||
|
||||
p.commandQueue.add(makeProjectorCommand());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -208,16 +208,20 @@ class Menu {
|
|||
} else if (theEvent.isFrom(animateList)){
|
||||
switch((int) animateList.getValue()) {
|
||||
case 0:
|
||||
// shrink.reset();
|
||||
parent.clickGetter = new Shrink(parent.operationSpeed)
|
||||
.makeClickGetter(parent.projectorApplet);
|
||||
break;
|
||||
case 1:
|
||||
// expand.reset();
|
||||
parent.clickGetter = new Expand(parent.operationSpeed)
|
||||
.makeClickGetter(parent.projectorApplet);
|
||||
break;
|
||||
case 2:
|
||||
// translate.reset();
|
||||
parent.clickGetter = new Translate(parent.operationSpeed)
|
||||
.makeClickGetter(parent.projectorApplet);
|
||||
break;
|
||||
case 3:
|
||||
// rotate.reset();
|
||||
parent.clickGetter = new Rotate(parent.operationSpeed)
|
||||
.makeClickGetter(parent.projectorApplet);
|
||||
break;
|
||||
}
|
||||
} else if (theEvent.isFrom(presetsList)){
|
||||
|
|
@ -247,7 +251,11 @@ class Menu {
|
|||
}
|
||||
// parent.lagTime = Integer.parseInt(lagField.getText());
|
||||
// parent.totalTime = Integer.parseInt(totaltimeField.getText());
|
||||
// parent.speed = Integer.parseInt(speedField.getText());
|
||||
try {
|
||||
parent.operationSpeed = Integer.parseInt(speedField.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
println("Ignored bad background color.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "Reset":
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class Rectangle {
|
|||
corner1y = y;
|
||||
corner1complete = true;
|
||||
return false;
|
||||
|
||||
} else {
|
||||
corner2x = x;
|
||||
corner2y = y;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import static processing.core.PApplet.*;
|
|||
public class Rotate {
|
||||
float centerx, centery, radius, speed;
|
||||
int timeElapsed, millisInit;
|
||||
PImage rotateRegion;
|
||||
PImage rotateRegion = null;
|
||||
|
||||
private boolean centercomplete;
|
||||
|
||||
|
|
@ -33,6 +33,11 @@ public class Rotate {
|
|||
|
||||
ProjectorCommand makeProjectorCommand() {
|
||||
return (ProjectorApplet p) -> {
|
||||
if (rotateRegion == null) {
|
||||
millisInit = p.millis();
|
||||
saveRotateRegion(p);
|
||||
}
|
||||
|
||||
timeElapsed = p.millis() - millisInit;
|
||||
|
||||
p.noFill();
|
||||
|
|
@ -65,8 +70,6 @@ public class Rotate {
|
|||
|
||||
} else {
|
||||
radius = sqrt(pow(x - centerx, 2) + pow(y - centery, 2));
|
||||
millisInit = p.millis();
|
||||
saveRotateRegion(p);
|
||||
|
||||
p.commandQueue.add(makeProjectorCommand());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import static processing.core.PApplet.*;
|
|||
class Shrink {
|
||||
float corner1x, corner1y, corner2x, corner2y, speed;
|
||||
int timeElapsed, millisInit;
|
||||
PImage shrinkRegion;
|
||||
PImage shrinkRegion = null;
|
||||
|
||||
private boolean corner1complete;
|
||||
|
||||
|
|
@ -46,6 +46,11 @@ class Shrink {
|
|||
|
||||
ProjectorCommand makeProjectorCommand() {
|
||||
return (ProjectorApplet p) -> {
|
||||
if (shrinkRegion == null) {
|
||||
millisInit = p.millis();
|
||||
saveShrinkRegion(p);
|
||||
}
|
||||
|
||||
timeElapsed = p.millis() - millisInit;
|
||||
|
||||
if (p.convertXDistance(corner2x-corner1x) - speed * aspectRatio() * (timeElapsed/1000f) < 25) {
|
||||
|
|
@ -79,8 +84,6 @@ class Shrink {
|
|||
} else {
|
||||
corner2x = x;
|
||||
corner2y = y;
|
||||
millisInit = p.millis();
|
||||
saveShrinkRegion(p);
|
||||
|
||||
p.commandQueue.add(makeProjectorCommand());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import static processing.core.PApplet.*;
|
|||
public class Translate {
|
||||
float corner1x, corner1y, corner2x, corner2y, endpointx, endpointy, speed;
|
||||
int timeElapsed, millisInit;
|
||||
PImage translateRegion;
|
||||
PImage translateRegion = null;
|
||||
|
||||
private boolean corner1complete, corner2complete;
|
||||
|
||||
|
|
@ -54,6 +54,11 @@ public class Translate {
|
|||
|
||||
ProjectorCommand makeProjectorCommand() {
|
||||
return (ProjectorApplet p) -> {
|
||||
if (translateRegion == null) {
|
||||
millisInit = p.millis();
|
||||
saveTranslateRegion(p);
|
||||
}
|
||||
|
||||
timeElapsed = p.millis() - millisInit;
|
||||
|
||||
float spaceElapsed = timeElapsed * speed / 1000f;
|
||||
|
|
@ -100,8 +105,6 @@ public class Translate {
|
|||
} else{
|
||||
endpointx = x;
|
||||
endpointy = y;
|
||||
millisInit = p.millis();
|
||||
saveTranslateRegion(p);
|
||||
|
||||
p.commandQueue.add(makeProjectorCommand());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ final int roiCornerX = 610;
|
|||
final int roiCornerY = 290;
|
||||
|
||||
|
||||
final int centerY = 540; // Center Y coordinate
|
||||
final int centerX = 860; // Center X coordinate
|
||||
|
||||
/* Global Variables */
|
||||
///////////////// Miscellaneaous Variables
|
||||
boolean load = false; // Boolean to determine if user wants to load previously saved led sequences or paint
|
||||
|
|
@ -75,11 +72,6 @@ boolean densityMeasured = false;
|
|||
FloatList fadeXCoord = new FloatList(); // Stores x-coordinate of each point
|
||||
FloatList fadeYCoord = new FloatList();
|
||||
|
||||
Shrink shrink = new Shrink();
|
||||
Expand expand = new Expand();
|
||||
Translate translate = new Translate();
|
||||
Rotate rotate = new Rotate();
|
||||
|
||||
|
||||
void setup() {
|
||||
count = 1;
|
||||
|
|
@ -102,23 +94,6 @@ void draw() {
|
|||
|
||||
recordTimelapse(lagTime, totalTime); //Note: the maximum fps is around 5
|
||||
|
||||
|
||||
for (int i=0; i < shrinkwindows.size(); i++) {
|
||||
shrinkwindows.get(i).draw();
|
||||
}
|
||||
|
||||
for (int i=0; i < expandwindows.size(); i++) {
|
||||
expandwindows.get(i).draw();
|
||||
}
|
||||
|
||||
for (int i=0; i < translatewindows.size(); i++) {
|
||||
translatewindows.get(i).draw();
|
||||
}
|
||||
|
||||
for (int i=0; i < rotatewindows.size(); i++) {
|
||||
rotatewindows.get(i).draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue