void generateGraph() { int m = 50 + int(testvalue/0.06); m = constrain(m, 5, 95); pg.beginDraw(); pg.background(255); pg.smooth(); if ((aStudy.k==0 && page==7) || (rel==0 && page==9)) { pg.noFill(); pg.beginShape(); for (int i=0;i<=m;i++) { pg.vertex(map(i, 0, 100, 50, 450), map(graphdata[i], 0, 0.4, 185, 50)); } pg.vertex(map(m, 0, 100, 50, 450), 185); pg.endShape(CLOSE); pg.fill(255, 0, 0); pg.beginShape(); for (int i=m;i<=100;i++) { pg.vertex(map(i, 0, 100, 50, 450), map(graphdata[i], 0, 0.4, 185, 50)); } pg.vertex(map(m, 0, 100, 50, 450), 185); pg.endShape(CLOSE); } else if ((aStudy.k == 1 && page==7) || (rel==1 && page==9)) { pg.fill(255, 0, 0); pg.beginShape(); for (int i=0;i<=m;i++) { pg.vertex(map(i, 0, 100, 50, 450), map(graphdata[i], 0, 0.4, 185, 50)); } pg.vertex(map(m, 0, 100, 50, 450), 185); pg.endShape(CLOSE); pg.noFill(); pg.beginShape(); for (int i=m;i<=100;i++) { pg.vertex(map(i, 0, 100, 50, 450), map(graphdata[i], 0, 0.4, 185, 50)); } pg.vertex(map(m, 0, 100, 50, 450), 185); pg.endShape(CLOSE); } else { if (m>50) { m = 100-m; } pg.fill(255, 0, 0); pg.beginShape(); for (int i=0;i<=m;i++) { pg.vertex(map(i, 0, 100, 50, 450), map(graphdata[i], 0, 0.4, 185, 50)); } pg.vertex(map(m, 0, 100, 50, 450), 185); pg.endShape(CLOSE); pg.noFill(); pg.beginShape(); pg.vertex(map(m, 0, 100, 50, 450), 185); for (int i=m;i<=100-m;i++) { pg.vertex(map(i, 0, 100, 50, 450), map(graphdata[i], 0, 0.4, 185, 50)); } pg.vertex(map(100-m, 0, 100, 50, 450), 185); pg.endShape(CLOSE); pg.fill(255, 0, 0); pg.beginShape(); for (int i=100-m;i<=100;i++) { pg.vertex(map(i, 0, 100, 50, 450), map(graphdata[i], 0, 0.4, 185, 50)); } pg.vertex(map(100-m, 0, 100, 50, 450), 185); pg.endShape(CLOSE); } pg.endDraw(); }