Finishing touches, moving caterpillar indicator, testing arduino sensor actuation
This commit is contained in:
parent
d8076ddb21
commit
6aba83b7c5
6 changed files with 241 additions and 59 deletions
|
|
@ -44,7 +44,7 @@
|
|||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
|
|
@ -60,28 +60,28 @@
|
|||
id="g823"
|
||||
transform="translate(-0.31738257,101.25041)">
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26548266px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26548266px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m -0.26681887,73.781194 c 0,0 71.16762787,-43.306649 210.65996887,-38.753048 l 0.26502,14.251867 c 0,0 -143.488711,9.256185 -194.984483,56.997557 C 4.1232136,116.98594 0.04306722,183.25283 9.528895e-4,168.37535 Z"
|
||||
id="path819"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccssc" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.46713138px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.46713138px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 21.840551,73.05283 c 0,0 12.33198,-9.425182 29.459736,-27.625527 C 68.42804,27.226957 67.05782,21.376847 88.638786,12.926686 110.21977,4.4765245 141.04972,-4.2986416 150.29871,-9.4987406 c 9.24899,-5.2000984 20.21075,-11.3752164 20.21075,-11.3752164 0,0 -20.55331,22.4254274 -62.34502,32.175611 -41.79173,9.750184 -49.327943,56.551078 -49.327943,56.551078 z"
|
||||
id="path838"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 62.910782,63.793078 c 0,0 8.544,1.823857 21.750501,7.009064 13.20651,5.185206 14.06575,8.562372 26.908507,7.579228 12.84276,-0.98315 30.32518,-4.098582 36.24315,-3.700619 5.91797,0.397968 12.93502,0.875873 12.93502,0.875873 0,0 -16.00121,-6.525862 -39.13714,-1.189422 C 98.474893,79.703648 82.492073,57.288164 82.492073,57.288164 Z"
|
||||
id="path838-6"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.1277611px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.1277611px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 71.06805,22.293829 c 0,0 3.2418,-2.707897 7.70807,-7.892643 4.46628,-5.1847471 4.0572,-6.8057181 9.78734,-9.3032131 5.73013,-2.497491 13.9394,-5.14681202 16.38398,-6.65702 2.44459,-1.51021 5.34179,-3.30344 5.34179,-3.30344 0,0 -5.35539,6.384696 -16.4987,9.378314 C 82.64721,7.5094419 80.95695,20.599801 80.95695,20.599801 Z"
|
||||
id="path838-6-7"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.08497027px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.08497027px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 135.47301,2.0526661 c 0,0 2.69725,-0.78318 7.21531,-1.32206 4.51807,-0.538884 5.26031,0.289 8.76535,-1.945578 3.50503,-2.234574 8.01425,-5.780914 9.75487,-6.569025 1.74063,-0.788116 3.80541,-1.720883 3.80541,-1.720883 0,0 -5.51005,0.583826 -11.29851,5.621484 -5.78846,5.037666 -13.63654,1.10793 -13.63654,1.10793 z"
|
||||
id="path838-6-7-5"
|
||||
inkscape:connector-curvature="0" />
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
|
@ -26,7 +26,7 @@
|
|||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.9899495"
|
||||
inkscape:cx="327.56796"
|
||||
inkscape:cx="129.57806"
|
||||
inkscape:cy="381.06641"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="g1048"
|
||||
|
|
@ -57,9 +57,10 @@
|
|||
id="g1048"
|
||||
transform="matrix(0.99928225,0,0,0.9973688,-33.107011,47.163965)">
|
||||
<g
|
||||
id="g841">
|
||||
id="g841"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none">
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 171.97916,141.27381 c 0,0 -0.21883,-29.00472 -18.07613,-54.852644 C 141.84055,68.961067 116.79757,53.557917 97.13988,47.157738 48.380952,31.28274 29.104167,46.02381 34.017858,54.339287 c 23.366394,31.129745 12.918351,36.823675 23.812499,66.901783 7.391783,17.74028 20.032738,29.86012 29.482144,32.12797 7.577013,1.81849 24.190469,1.88988 24.190469,1.88988 0,0 -31.749995,4.15774 -33.261898,28.34822 -1.511906,24.19048 -18.520836,60.4762 4.535712,66.52381 12.000726,3.14773 35.226046,-22.41985 55.465206,-36.4263 18.64559,-12.90363 30.02684,-8.20895 34.8711,-14.22251 z"
|
||||
id="path830"
|
||||
inkscape:connector-curvature="0"
|
||||
|
|
@ -69,7 +70,7 @@
|
|||
inkscape:connector-curvature="0"
|
||||
id="path860"
|
||||
d="m 163.56895,130.49108 c 0,0 -4.27631,-52.919362 -51.04848,-70.559151 -46.772166,-17.639789 61.20472,105.036921 51.31575,71.628231"
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path860-6"
|
||||
|
|
@ -80,7 +81,7 @@
|
|||
inkscape:connector-curvature="0"
|
||||
id="path892"
|
||||
d="m 164.04856,146.10309 c 2.21944,-2.53395 -83.372498,-24.71697 -95.163275,-21.67193 -5.797363,1.49721 8.405196,17.53418 18.013701,21.15999 16.773444,6.32955 60.773494,10.92128 77.149574,0.51194 z"
|
||||
style="fill:#00c800;fill-opacity:1;stroke:#000000;stroke-width:0.24669409px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
style="fill:#00c800;fill-opacity:1;stroke:none;stroke-width:0.24669409px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<ellipse
|
||||
inkscape:transform-center-y="-28.544916"
|
||||
inkscape:transform-center-x="21.20484"
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
|
|
@ -25,9 +25,9 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.49497475"
|
||||
inkscape:cx="485.93916"
|
||||
inkscape:cy="406.59149"
|
||||
inkscape:zoom="0.9899495"
|
||||
inkscape:cx="178.03689"
|
||||
inkscape:cy="351.5392"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="g1048"
|
||||
showgrid="false"
|
||||
|
|
@ -61,12 +61,12 @@
|
|||
inkscape:connector-curvature="0"
|
||||
id="path830"
|
||||
d="m 171.97916,141.27381 c 0,0 -0.21883,-29.00472 -18.07613,-54.852644 C 141.84055,68.961067 116.79757,53.557917 97.13988,47.157738 48.380952,31.28274 29.104167,46.02381 34.017858,54.339287 c 23.366394,31.129745 12.918351,36.823675 23.812499,66.901783 7.391783,17.74028 20.032738,29.86012 29.482144,32.12797 7.577013,1.81849 24.190469,1.88988 24.190469,1.88988 0,0 -31.749995,4.15774 -33.261898,28.34822 -1.511906,24.19048 -18.520836,60.4762 4.535712,66.52381 12.000726,3.14773 35.226046,-22.41985 55.465206,-36.4263 18.64559,-12.90363 30.02684,-8.20895 34.8711,-14.22251 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path860"
|
||||
d="m 163.56895,130.49108 c 0,0 -4.27631,-52.919362 -51.04848,-70.559151 -46.772166,-17.639789 61.20472,105.036921 51.31575,71.628231"
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path860-6"
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
inkscape:connector-curvature="0"
|
||||
id="path892"
|
||||
d="m 164.04856,146.10309 c 2.21944,-2.53395 -83.372498,-24.71697 -95.163275,-21.67193 -5.797363,1.49721 8.405196,17.53418 18.013701,21.15999 16.773444,6.32955 60.773494,10.92128 77.149574,0.51194 z"
|
||||
style="fill:#00c800;fill-opacity:1;stroke:#000000;stroke-width:0.24669409px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
style="fill:#00c800;fill-opacity:1;stroke:none;stroke-width:0.24669409px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<ellipse
|
||||
inkscape:transform-center-y="-28.544916"
|
||||
inkscape:transform-center-x="21.20484"
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
|
|
@ -64,8 +64,8 @@ void draw() {
|
|||
}*/
|
||||
|
||||
// Set up fill and let background move
|
||||
background(255);
|
||||
translate(0, backgroundOffset);
|
||||
background(0);
|
||||
translate(0, backgroundOffset - 100);
|
||||
|
||||
// TODO: Only start to move background as soon as second sensor is triggered
|
||||
backgroundOffset = backgroundOffset + velocity;
|
||||
|
|
@ -79,7 +79,7 @@ void draw() {
|
|||
|
||||
/* START - Create and animate placementIndicator */
|
||||
// TODO: Trigger when first sensor is actuated
|
||||
placementIndicator(width / 2, (height / 2) - backgroundOffset ,80, 8, placementIndicatorOffsetX);
|
||||
placementIndicator(width / 2+ 150, (height / 2) - backgroundOffset ,130, 8, placementIndicatorOffsetX);
|
||||
|
||||
if (placementIndicatorAnimationCounter < 5) {
|
||||
if (placementIndicatorAnimationDirection == "right" && placementIndicatorOffsetX < 30) {
|
||||
|
|
@ -126,9 +126,9 @@ void draw() {
|
|||
cocoonAnimationFinished = true;
|
||||
}
|
||||
|
||||
fill(0);
|
||||
fill(255);
|
||||
noStroke();
|
||||
arc(width / 2, -1900 - (backgroundOffset - 2450), 300, 700, radians(260 - cocoonOpenDegrees), radians(280 + cocoonOpenDegrees), PIE);
|
||||
arc(width / 2 + 150, -1800 - (backgroundOffset - 2450), 500, 1100, radians(260 - cocoonOpenDegrees), radians(280 + cocoonOpenDegrees), PIE);
|
||||
|
||||
print("Tree position: ");
|
||||
shape(branch, 0, -3200 - (backgroundOffset - 2450), width, width);
|
||||
|
|
@ -141,33 +141,34 @@ void draw() {
|
|||
treeOffset = treeOffset + velocity;
|
||||
/* START - Scene 4 Butterfly */
|
||||
|
||||
if (wingWidth < 500 && wingsSpread == false) {
|
||||
if (wingWidth < 620 && wingsSpread == false) {
|
||||
wingDirection = "bigger";
|
||||
} else if (wingWidth >= 500 && wingsSpread == false) {
|
||||
wingWidth = 500;
|
||||
} else if (wingWidth >= 620 && wingsSpread == false) {
|
||||
wingWidth = 620;
|
||||
wingsSpread = true;
|
||||
} else if (wingsSpread == true && wingWidth < 450) {
|
||||
} else if (wingsSpread == true && wingWidth < 540) {
|
||||
wingDirection = "bigger";
|
||||
} else if (wingsSpread == true && wingWidth >= 500) {
|
||||
} else if (wingsSpread == true && wingWidth >= 620) {
|
||||
wingDirection = "smaller";
|
||||
}
|
||||
|
||||
if (wingDirection == "smaller") {
|
||||
wingWidth -= 3;
|
||||
wingWidth -= 4;
|
||||
} else if (wingDirection == "bigger") {
|
||||
wingWidth += 3;
|
||||
wingWidth += 4;
|
||||
}
|
||||
|
||||
shape(leftWing, width / 2 - wingWidth - 20, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5);
|
||||
shape(rightWing, width / 2 + 20, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5);
|
||||
shape(leftWing, width / 2 - wingWidth + 85, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5);
|
||||
shape(rightWing, width / 2 + 215, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5);
|
||||
|
||||
|
||||
/* END - Scene 4 Butterfly */
|
||||
} else if (backgroundOffset > 13000) {
|
||||
background(0);
|
||||
background(255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bug(float x, float y, float scale) {
|
||||
PShape leftUpperLeg = bugLeg(scale, false);
|
||||
PShape leftMiddleLeg = bugLeg(scale, false);
|
||||
|
|
@ -230,8 +231,8 @@ void polygon(float x, float y, float radius, int npoints) {
|
|||
float sy = y + sin(a) * radius;
|
||||
vertex(sx, sy);
|
||||
}
|
||||
fill(0);
|
||||
stroke(0);
|
||||
fill(255);
|
||||
stroke(255);
|
||||
endShape(CLOSE);
|
||||
}
|
||||
|
||||
|
|
@ -256,8 +257,8 @@ void head(float x, float y, float polygonRadius, int npoints) {
|
|||
|
||||
PShape antenna(float scale) {
|
||||
PShape antenna = createShape(RECT, 0, 0, 5 * scale, 25 * scale);
|
||||
antenna.setFill(color(0));
|
||||
antenna.setStroke(color(0));
|
||||
antenna.setFill(color(255));
|
||||
antenna.setStroke(color(255));
|
||||
antenna.endShape();
|
||||
|
||||
return antenna;
|
||||
|
|
@ -266,8 +267,8 @@ PShape antenna(float scale) {
|
|||
PShape bugLeg(float scale, boolean mirrored) {
|
||||
PShape bugLeg = createShape();
|
||||
bugLeg.beginShape();
|
||||
bugLeg.fill(0);
|
||||
bugLeg.stroke(0);
|
||||
bugLeg.fill(255);
|
||||
bugLeg.stroke(255);
|
||||
|
||||
if (mirrored == true) {
|
||||
bugLeg.vertex(0, 20);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -22,24 +22,82 @@ Serial arduinoPort;
|
|||
String receivedMessage;
|
||||
boolean cameIntoThreshhold = false;
|
||||
|
||||
PShape branch;
|
||||
PShape leftWing;
|
||||
PShape rightWing;
|
||||
ArrayList<PShape> flyOverObjects = new ArrayList<PShape>();
|
||||
float velocity = 6;
|
||||
float backgroundOffset = 0;
|
||||
float placementIndicatorOffsetX = 0;
|
||||
int placementIndicatorAnimationCounter = 0;
|
||||
String placementIndicatorAnimationDirection = "right";
|
||||
float cocoonOpenDegrees = 0;
|
||||
String cocoonAnimationDirection = "close";
|
||||
boolean cocoonAnimationFinished = false;
|
||||
float wingOpacity = 0;
|
||||
float treeOffset = 0;
|
||||
float wingWidth = 100;
|
||||
boolean wingsSpread = false;
|
||||
String wingDirection = "smaller";
|
||||
|
||||
public void setup() {
|
||||
/* Set up screen */
|
||||
|
||||
background(0);
|
||||
|
||||
|
||||
/* Load external files */
|
||||
branch = loadShape("branch.svg");
|
||||
leftWing = loadShape("leftwing.svg");
|
||||
rightWing = loadShape("rightwing.svg");
|
||||
|
||||
/* Spawn random objects the butterfly can fly over */
|
||||
for (int i = 0; i < 40; i++) {
|
||||
float x = random(5, width / 10 - 5) * 10;
|
||||
float y = random(4800, 12000);
|
||||
float radius = random(1, 10) * 25;
|
||||
PShape object = createShape(ELLIPSE, x, -y, radius, radius);
|
||||
object.setFill(color(150, 150, 150));
|
||||
object.setStroke(color(150, 150, 150));
|
||||
flyOverObjects.add(object);
|
||||
}
|
||||
|
||||
|
||||
/* Set up communication with arduino
|
||||
String portName = Serial.list()[Serial.list().length - 1]; //change index to match your port
|
||||
arduinoPort = new Serial(this, portName, 9600); */
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
/* START - Create and animate placementIndicator */
|
||||
/* if ( arduinoPort.available() > 0) {
|
||||
String rec = arduinoPort.readStringUntil('\n');
|
||||
if (rec != null) {
|
||||
receivedMessage = rec;
|
||||
}
|
||||
|
||||
// Check for specific events and act upon them
|
||||
if (receivedMessage != null && receivedMessage.contains("isWithinThreshhold")) {
|
||||
cameIntoThreshhold = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
// Set up fill and let background move
|
||||
background(0);
|
||||
placementIndicator(80, 8, placementIndicatorOffsetX);
|
||||
translate(0, backgroundOffset - 100);
|
||||
|
||||
// TODO: Only start to move background as soon as second sensor is triggered
|
||||
backgroundOffset = backgroundOffset + velocity;
|
||||
println(backgroundOffset);
|
||||
|
||||
// Draw fly-over objects
|
||||
for (int i = 0; i < flyOverObjects.size(); i++) {
|
||||
PShape object = flyOverObjects.get(i);
|
||||
shape(object);
|
||||
}
|
||||
|
||||
/* START - Create and animate placementIndicator */
|
||||
// TODO: Trigger when first sensor is actuated
|
||||
placementIndicator(width / 2 + 100, (height / 2) - backgroundOffset ,130, 8, placementIndicatorOffsetX);
|
||||
|
||||
if (placementIndicatorAnimationCounter < 5) {
|
||||
if (placementIndicatorAnimationDirection == "right" && placementIndicatorOffsetX < 30) {
|
||||
|
|
@ -60,32 +118,127 @@ public void draw() {
|
|||
}
|
||||
/* END - Create and animate placementIndicator */
|
||||
|
||||
/* if ( arduinoPort.available() > 0) {
|
||||
String rec = arduinoPort.readStringUntil('\n');
|
||||
if (rec != null) {
|
||||
receivedMessage = rec;
|
||||
/* START - Scene 1 Bugs going by */
|
||||
bug(100, -100, 1);
|
||||
bug(400, -400, 1);
|
||||
bug(width - 200, -600, 1);
|
||||
bug(width - 400, -300, 1);
|
||||
/* END - Scene 1 Bugs going by */
|
||||
|
||||
|
||||
if (backgroundOffset < 2450) {
|
||||
/* START - Scene 2 Crawling on branch */
|
||||
shape(branch, 0, -3200, width, width);
|
||||
/* END - Scene 2 Crawling on branch */
|
||||
} else if (backgroundOffset > 2450 && backgroundOffset < 4400) {
|
||||
if (cocoonAnimationFinished == false) {
|
||||
if (cocoonAnimationDirection == "close" && cocoonOpenDegrees < 165) {
|
||||
cocoonOpenDegrees++;
|
||||
} else if (cocoonAnimationDirection == "close" && cocoonOpenDegrees >= 165) {
|
||||
cocoonOpenDegrees = 165;
|
||||
cocoonAnimationDirection = "open";
|
||||
} if (cocoonAnimationDirection == "open" && cocoonOpenDegrees > 0) {
|
||||
cocoonOpenDegrees--;
|
||||
} if (cocoonAnimationDirection == "open" && cocoonOpenDegrees <= 0) {
|
||||
cocoonOpenDegrees = 0;
|
||||
cocoonAnimationFinished = true;
|
||||
}
|
||||
|
||||
fill(255);
|
||||
noStroke();
|
||||
arc(width / 2 + 100, -1800 - (backgroundOffset - 2450), 500, 1100, radians(260 - cocoonOpenDegrees), radians(280 + cocoonOpenDegrees), PIE);
|
||||
|
||||
print("Tree position: ");
|
||||
shape(branch, 0, -3200 - (backgroundOffset - 2450), width, width);
|
||||
}
|
||||
|
||||
// Check for specific events and act upon them
|
||||
if (receivedMessage != null && receivedMessage.contains("isWithinThreshhold")) {
|
||||
cameIntoThreshhold = true;
|
||||
// 3. Let tree move again
|
||||
/* END - Scene 3 Cocooning */
|
||||
} else if (backgroundOffset > 4400 && backgroundOffset < 13000) {
|
||||
shape(branch, 0, -3200 - (backgroundOffset - 2450) + treeOffset, width, width);
|
||||
treeOffset = treeOffset + velocity;
|
||||
/* START - Scene 4 Butterfly */
|
||||
|
||||
if (wingWidth < 620 && wingsSpread == false) {
|
||||
wingDirection = "bigger";
|
||||
} else if (wingWidth >= 620 && wingsSpread == false) {
|
||||
wingWidth = 620;
|
||||
wingsSpread = true;
|
||||
} else if (wingsSpread == true && wingWidth < 540) {
|
||||
wingDirection = "bigger";
|
||||
} else if (wingsSpread == true && wingWidth >= 620) {
|
||||
wingDirection = "smaller";
|
||||
}
|
||||
|
||||
if (wingDirection == "smaller") {
|
||||
wingWidth -= 4;
|
||||
} else if (wingDirection == "bigger") {
|
||||
wingWidth += 4;
|
||||
}
|
||||
|
||||
shape(leftWing, width / 2 - wingWidth + 35, (height / 2 - wingWidth * 0.8f) - backgroundOffset, wingWidth, wingWidth * 1.5f);
|
||||
shape(rightWing, width / 2 + 165, (height / 2 - wingWidth * 0.8f) - backgroundOffset, wingWidth, wingWidth * 1.5f);
|
||||
|
||||
|
||||
/* END - Scene 4 Butterfly */
|
||||
} else if (backgroundOffset > 13000) {
|
||||
background(255);
|
||||
}
|
||||
|
||||
circle(width / 2, height / 2, radius);
|
||||
fill(0);
|
||||
radius += 10; */
|
||||
}
|
||||
|
||||
public void placementIndicator(float polygonRadius, int npoints, float offsetX) {
|
||||
float centerX = width / 2;
|
||||
float centerY = height / 2;
|
||||
|
||||
polygon(centerX + offsetX, centerY + polygonRadius * 2.75f, polygonRadius * 0.8f, npoints);
|
||||
polygon(centerX + offsetX * 0.9f, centerY + polygonRadius * 1.6f, polygonRadius, npoints);
|
||||
polygon(centerX + offsetX * 0.7f, centerY, polygonRadius, npoints);
|
||||
polygon(centerX + offsetX * 0.3f, centerY - polygonRadius * 1.6f, polygonRadius, npoints);
|
||||
head(centerX, centerY, polygonRadius, 8);
|
||||
public void bug(float x, float y, float scale) {
|
||||
PShape leftUpperLeg = bugLeg(scale, false);
|
||||
PShape leftMiddleLeg = bugLeg(scale, false);
|
||||
PShape leftLowerLeg = bugLeg(scale, false);
|
||||
PShape rightUpperLeg = bugLeg(scale, true);
|
||||
PShape rightMiddleLeg = bugLeg(scale, true);
|
||||
PShape rightLowerLeg = bugLeg(scale, true);
|
||||
|
||||
pushMatrix();
|
||||
|
||||
translate(x, y);
|
||||
polygon(60 * scale, 40 * scale , 40 * scale, 6);
|
||||
|
||||
pushMatrix();
|
||||
leftUpperLeg.translate(5 * scale, 0);
|
||||
shape(leftUpperLeg);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
leftMiddleLeg.translate(0, 20 * scale);
|
||||
shape(leftMiddleLeg);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
leftLowerLeg.translate(5 * scale, 45 * scale);
|
||||
shape(leftLowerLeg);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
rightUpperLeg.translate(85 * scale, 0);
|
||||
shape(rightUpperLeg);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
rightMiddleLeg.translate(90 * scale, 20 * scale);
|
||||
shape(rightMiddleLeg);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
rightLowerLeg.translate(85 * scale, 45 * scale);
|
||||
shape(rightLowerLeg);
|
||||
popMatrix();
|
||||
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
public void placementIndicator(float x, float y, float polygonRadius, int npoints, float offsetX) {
|
||||
polygon(x + offsetX, y + polygonRadius * 2.75f, polygonRadius * 0.8f, npoints);
|
||||
polygon(x + offsetX * 0.9f, y + polygonRadius * 1.6f, polygonRadius, npoints);
|
||||
polygon(x + offsetX * 0.7f, y, polygonRadius, npoints);
|
||||
polygon(x + offsetX * 0.3f, y - polygonRadius * 1.6f, polygonRadius, npoints);
|
||||
head(x, y, polygonRadius, 8);
|
||||
}
|
||||
|
||||
public void polygon(float x, float y, float radius, int npoints) {
|
||||
|
|
@ -128,6 +281,33 @@ public PShape antenna(float scale) {
|
|||
|
||||
return antenna;
|
||||
}
|
||||
|
||||
public PShape bugLeg(float scale, boolean mirrored) {
|
||||
PShape bugLeg = createShape();
|
||||
bugLeg.beginShape();
|
||||
bugLeg.fill(255);
|
||||
bugLeg.stroke(255);
|
||||
|
||||
if (mirrored == true) {
|
||||
bugLeg.vertex(0, 20);
|
||||
bugLeg.vertex(15, 20);
|
||||
bugLeg.vertex(30, 5);
|
||||
bugLeg.vertex(30, 0);
|
||||
bugLeg.vertex(15, 15);
|
||||
bugLeg.vertex(0, 15);
|
||||
} else {
|
||||
bugLeg.vertex(0, 0);
|
||||
bugLeg.vertex(15, 15);
|
||||
bugLeg.vertex(30, 15);
|
||||
bugLeg.vertex(30, 20);
|
||||
bugLeg.vertex(15, 20);
|
||||
bugLeg.vertex(0, 5);
|
||||
}
|
||||
|
||||
bugLeg.endShape(CLOSE);
|
||||
|
||||
return bugLeg;
|
||||
}
|
||||
public void settings() { fullScreen(); }
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "magic_veneer_processing" };
|
||||
|
|
|
|||
Reference in a new issue