import gifAnimation.*; import processing.serial.*; Serial port; PImage bg; //Background Image. Gif g1; // Moving Image of Data 1. Gif g2; // Moving Image of Data 2. Gif g3; // Moving Image of Data 3. Gif g4; // Moving Image of Data 4. Gif g5; // Moving Image of Data 5. Gif g6; // Moving Image of Data 6. Gif g7; // Moving Image of Data 7. Gif g8; // Moving Image of Data 8. int y; int g1x,g1y,g2x,g2y,g3x,g3y,g4x,g4y,g5x,g5y,g6x,g6y,g7x,g7y,g8x,g8y; String[] gcode1,gcode2,gcode3,gcode4,gcode5,gcode6,gcode7,gcode8; String[] sendgcode; int gcodesend; Serial s; void setup() { // Serial Connection Check println(Serial.list()); // s = new Serial (this, Serial.list ()[1], 250000); gcodesend = 0; // Background // The background image must be the same size as the parameters // into the size() method. In this program, the size of the image // is 640 x 360 pixels. size(500, 332); bg = loadImage("https://fab.sfc.keio.ac.jp/gcode/bg.jpg"); // Load G-code (1) g1 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g1.play(); g1.loop(); g1x = 20; g1y = 180; gcode1 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE1 : there are " + gcode1.length + " lines"); // Load G-code (2) g2 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g2.play(); g2.loop(); g2x = 80; g2y = 180; gcode2 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE2 : there are " + gcode2.length + " lines"); // Load G-code (3) g3 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g3.play(); g3.loop(); g3x = 130; g3y = 180; gcode3 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE3 : there are " + gcode3.length + " lines"); // Load G-code (4) g4 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g4.play(); g4.loop(); g4x = 180; g4y = 180; gcode4 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE4: there are " + gcode4.length + " lines"); // Load G-code (5) g5 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g5.play(); g5.loop(); g5x = 230; g5y = 180; gcode5 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE5: there are " + gcode5.length + " lines"); // Load G-code (6) g6 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g6.play(); g6.loop(); g6x = 280; g6y = 180; gcode6 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE6: there are " + gcode6.length + " lines"); // Load G-code (7) g7 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g7.play(); g7.loop(); g7x = 330; g7y = 180; gcode7 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE7: there are " + gcode7.length + " lines"); // Load G-code (8) g8 = new Gif(this, "https://fab.sfc.keio.ac.jp/gcode/gifanime.gif"); g8.play(); g8.loop(); g8x = 380; g8y = 180; gcode8 = loadStrings("https://fab.sfc.keio.ac.jp/gcode/bunny3_headcut.gcode"); println("G-CODE8: there are " + gcode8.length + " lines"); } void draw() { background(bg); stroke(226, 204, 0); line(0, y, width, y); y++; if (y > height) { y = 0; } image(g1, g1x, g1y); image(g2, g2x, g2y); image(g3, g3x, g3y); image(g4, g4x, g4y); image(g5, g5x, g5y); image(g6, g6x, g6y); image(g7, g7x, g7y); image(g8, g8x, g8y); if (gcodesend>0) { printstart(gcodesend); } } void mouseClicked() { if (g1x<=mouseX && mouseX<=g1x+g1.width && g1y<=mouseY && mouseY<=g1y+g1.height) { println("click_g1"); gcodesend = 1; } if (g2x<=mouseX && mouseX<=g2x+g2.width && g2y<=mouseY && mouseY<=g2y+g2.height) { println("click_g2"); gcodesend = 2; } if (g3x<=mouseX && mouseX<=g3x+g3.width && g3y<=mouseY && mouseY<=g3y+g3.height) { println("click_g3"); gcodesend = 3; } if (g4x<=mouseX && mouseX<=g4x+g4.width && g4y<=mouseY && mouseY<=g4y+g4.height) { println("click_g4"); gcodesend = 4; } if (g5x<=mouseX && mouseX<=g5x+g5.width && g5y<=mouseY && mouseY<=g5y+g5.height) { println("click_g5"); gcodesend = 5; } if (g6x<=mouseX && mouseX<=g6x+g6.width && g6y<=mouseY && mouseY<=g6y+g6.height) { println("click_g6"); gcodesend = 6; } if (g7x<=mouseX && mouseX<=g7x+g7.width && g7y<=mouseY && mouseY<=g7y+g7.height) { println("click_g7"); gcodesend = 7; } if (g8x<=mouseX && mouseX<=g8x+g8.width && g8y<=mouseY && mouseY<=g8y+g8.height) { println("click_g8"); gcodesend = 8; } } void printstart(int gcodesend){ println("Print Start!"); if (gcodesend == 1) { sendgcode = gcode1; } if (gcodesend == 2) { sendgcode = gcode2; } if (gcodesend == 3) { sendgcode = gcode3; } if (gcodesend == 4) { sendgcode = gcode4; } if (gcodesend == 5) { sendgcode = gcode5; } if (gcodesend == 6) { sendgcode = gcode6; } if (gcodesend == 7) { sendgcode = gcode7; } if (gcodesend == 8) { sendgcode = gcode8; } for (int i = 0 ; i < sendgcode.length; i++) { println( sendgcode[i]); s.write( sendgcode[i] + "\n"); } println("Print Finish!"); }