void generateGraph(float testvalue, int c, int colour) { int m = 50 + int(testvalue/0.06); m = constrain(m, 10, 90); pg.beginDraw(); pg.background(255); pg.smooth(); if (c==0) { pg.noFill(); pg.beginShape(); for (int i=0;i<=m;i++) { pg.vertex(map(i, 0, 100, 5, gwidth-5), map(graphdata[i], 0, 0.4, gheight-5, 5)); } pg.vertex(map(m, 0, 100, 5, gwidth-5), gheight-5); pg.endShape(CLOSE); if (colour ==0) { pg.fill(255, 0, 0); } else if (colour ==1) { pg.fill(0, 255, 0); } else { pg.fill(0, 0, 255); } pg.beginShape(); for (int i=m;i<=100;i++) { pg.vertex(map(i, 0, 100, 5, gwidth-5), map(graphdata[i], 0, 0.4, gheight-5, 5)); } pg.vertex(map(m, 0, 100, 5, gwidth-5), gheight-5); pg.endShape(CLOSE); } else if (c == 1) { if (colour ==0) { pg.fill(255, 0, 0); } else if (colour ==1) { pg.fill(0, 255, 0); } else { pg.fill(0, 0, 255); } pg.beginShape(); for (int i=0;i<=m;i++) { pg.vertex(map(i, 0, 100, 5, gwidth-5), map(graphdata[i], 0, 0.4, gheight-5, 5)); } pg.vertex(map(m, 0, 100, 5, gwidth-5), gheight-5); pg.endShape(CLOSE); pg.noFill(); pg.beginShape(); for (int i=m;i<=100;i++) { pg.vertex(map(i, 0, 100, 5, gwidth-5), map(graphdata[i], 0, 0.4, gheight-5, 5)); } pg.vertex(map(m, 0, 100, 5, gwidth-5), gheight-5); pg.endShape(CLOSE); } else { if (m>50) { m = 100-m; } if (colour ==0) { pg.fill(255, 0, 0); } else if (colour ==1) { pg.fill(0, 255, 0); } else { pg.fill(0, 0, 255); } pg.beginShape(); for (int i=0;i<=m;i++) { pg.vertex(map(i, 0, 100, 5, gwidth-5), map(graphdata[i], 0, 0.4, gheight-5, 5)); } pg.vertex(map(m, 0, 100, 5, gwidth-5), gheight-5); pg.endShape(CLOSE); pg.noFill(); pg.beginShape(); pg.vertex(map(m, 0, 100, 5, gwidth-5), gheight-5); for (int i=m;i<=100-m;i++) { pg.vertex(map(i, 0, 100, 5, gwidth-5), map(graphdata[i], 0, 0.4, gheight-5, 5)); } pg.vertex(map(100-m, 0, 100, 5, gwidth-5), gheight-5); pg.endShape(CLOSE); if (colour ==0) { pg.fill(255, 0, 0); } else if (colour ==1) { pg.fill(0, 255, 0); } else { pg.fill(0, 0, 255); } pg.beginShape(); for (int i=100-m;i<=100;i++) { pg.vertex(map(i, 0, 100, 5, gwidth-5), map(graphdata[i], 0, 0.4, gheight-5, 5)); } pg.vertex(map(100-m, 0, 100, 5, gwidth-5), gheight-5); pg.endShape(CLOSE); } pg.endDraw(); }