/* plusses.pde Written by Justin Hsia Use arrays to draw a bunch of different plusses */ // arrays to hold arguments for each individual plus int[] xArr = {0, 70, 100, 150, 20, 400}; int[] yArr = {0, 50, 130, 350, 200, 100}; color[] cArr = {color(255,0,0), color(0,255,0), color(0,0,255), color(255,255,0), color(0,255,255), color(255,0,255)}; void setup() { size(500,500); // drawing canvas size background(255); // white background } void draw() { // draw plusses of arbitrary colors in arbitrary locations // based on values in xArr[], yArr[], and cArr[] for(int i = 0; i < xArr.length; i = i+1) { drawPlus(xArr[i],yArr[i],cArr[i]); } } // draw a plus (+) of size 50x50 using a custom shape void drawPlus(int x, int y, color c) { fill(c); beginShape(); vertex(x, y+20); // upper W point vertex(x+20, y+20); // NW point vertex(x+20, y); // left N point vertex(x+30, y); // right N point vertex(x+30, y+20); // NE point vertex(x+50, y+20); // upper E point vertex(x+50, y+30); // lower E point vertex(x+30, y+30); // SE point vertex(x+30, y+50); // right S point vertex(x+20, y+50); // left S point vertex(x+20, y+30); // SW point vertex(x, y+30); // lower W point endShape(); }