1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- Node nodes[] = new Node[1000];
- Link links[] = new Link[6000];
-
- int textSize = 14;
- boolean darkMode = true;
-
- void setup() {
- size(800, 600);
- surface.setResizable(true);
-
- textSize(textSize);
-
- initButtons();
-
- /**
- * When saving, a copy of the save-file is stored locally which is opened when starting the program
- */
- try {
- loadCSV(dataPath("save.csv"));
- }
- catch(Exception e) {
- println("No File found, starting blank");
- }
- }
-
- void draw() {
- background(darkMode? 0 : 255);
-
- /**
- * Update and display links
- */
- for (int i = 0; i < linkCount; i++) {
- if (links[i].active) {
- links[i].update();
- links[i].display();
- }
- }
-
- /**
- * Update and display nodes
- */
- for (int i = 0; i < nodeCount; i++) {
- if (!nodes[i].deleted) {
- nodes[i].update();
- nodes[i].display();
- }
- }
-
- /**
- * Update and display ui, hide via exporting-flag for easy image-saving
- * Not all buttons always show, that's why this isn't in a loop
- */
- if (!exporting) {
- textSize(14);
- rectMode(CORNER);
- textAlign(CORNER);
- buttons[0].display();
- if (i_selectedNode != -1) buttons[1].display();
- buttons[2].display();
- buttons[3].display();
- buttons[4].display();
- buttons[5].display();
- rectMode(CENTER);
- textAlign(CENTER);
- textSize(textSize);
- } else {
- save(savePNGpath);
- exporting = false;
- }
-
- /**
- * Pull "wire" out of in/outlet before creating a link (see mouseReleased in ui)
- */
- if (dragLink) {
- stroke(darkMode? 255:0);
- strokeWeight(2);
- if (dragOriginLet == -1) {
- line(nodes[dragOriginId].inletCenter.x, nodes[dragOriginId].inletCenter.y, mouseX, mouseY);
- } else if (dragOriginLet == 1) {
- line(nodes[dragOriginId].outletCenter.x, nodes[dragOriginId].outletCenter.y, mouseX, mouseY);
- }
- }
- }
|