int margin = 16; float s=72; float w; int smargin = int(s+margin); color lightBlue = color(180,180,255); color darkBlue = color(0,0,192); HSlider LineWidthSlider; int inputSelect = 0; int select = 1; // may need to get rid of select value void setup() { size(440, 576); smooth(); loop(); int selectThis = 1; // define and create horizontal sliders: inputSelect, xpos, ypos, length, width, value, LineWidthSlider = new HSlider(selectThis, margin, margin/2, smargin*5-margin*2, margin, .5 ); selectThis ++; } void draw () { background(255); LineWidthSlider.display(); if ( select == 1) { w = LineWidthSlider.value*(s*.3); } float a = s - (w + w*sqrt(2)); float b = (s + w) / 4; float theta = tan( PI/4 - asin( (w/2) / ( s*sqrt(2)/2) ) ); float n = (s-w) * theta; float x = s * theta; float r = (s/2) * theta; translate(-margin/2,margin*2); //grid lines stroke(230); for ( int i=0; i < 8; i++ ) { line( 0, 0+(s+margin)*i, width+margin , 0+(s+margin)*i ); line( 0, margin+(s+margin)*i, width+margin, margin+(s+margin)*i ); } for ( int j=0; j < 6; j++ ) { line( 0+(s+margin)*j, 0 , 0+(s+margin)*j , height); line( margin+(s+margin)*j, 0 , margin+(s+margin)*j , height); } translate(margin,margin); stroke(darkBlue); fill(lightBlue); noStroke(); ellipseMode(RADIUS); strokeCap(SQUARE); // AAAAAAAAAAAAAAAA pushMatrix(); translate( (s+margin)*0,(s+margin)*0 ); beginShape(); vertex(s, 0); vertex(s, s); vertex(s-w, s); //horizontal stroke vertex(s-w, s - (a/2 - w/2) ); vertex( s - (a/2 + w/2 + w + 1 ), s - (a/2 - w/2) ); vertex( s - (a/2 - w/2 + w + 1 ), s - (a/2 + w/2) ); vertex( s-w, s - (a/2 + w/2) ); vertex(s-w, s-a); vertex(w*sqrt(2), s); vertex(0, s); endShape(CLOSE); popMatrix(); // BBBBBBBBBBBBB pushMatrix(); translate( (s+margin)*1,(s+margin)*0 ); beginShape(); vertex(0, 0); vertex(s-b-s/8, 0); vertex(s-b-s/8, w); vertex(w, w); vertex(w, s/2 - w/2); vertex(s-b, s/2 - w/2); vertex(s-b, s/2 + w/2); vertex(w, s/2 + w/2); vertex(w, s-w); vertex(s-b, s-w); vertex(s-b, s); vertex(0,s); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s-b-s/8-1, b, b - w/2, b - w/2, -PI/2, PI/2); arc(s-b-1, s-b, b - w/2, b - w/2, -PI/2, PI/2); strokeWeight(1); fill(lightBlue); popMatrix(); // CCCCCCCCCCCC pushMatrix(); translate( (s+margin)*2,(s+margin)*0 ); strokeWeight(w); stroke(lightBlue); noFill(); arc(s/2, s/2, s/2 - w/2, s/2 - w/2, PI/4, (7.0/4.0)*PI); strokeWeight(1); fill(lightBlue); popMatrix(); // DDDDDDDDDDDD pushMatrix(); translate( (s+margin)*3,(s+margin)*0 ); beginShape(); vertex(0, 0); vertex(s/2, 0); vertex(s/2, w); vertex(w, w); vertex(w, s/2 - w/2); vertex(w, s-w); vertex(s/2, s-w); vertex(s/2, s); vertex(0,s); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s/2, s/2, s/2 - w/2, s/2 - w/2, -PI/2, PI/2); strokeWeight(1); fill(lightBlue); popMatrix(); // EEEEEE pushMatrix(); translate( (s+margin)*4,(s+margin)*0 ); beginShape(); vertex(0, 0); vertex(s, 0); vertex(s, w); vertex(w, w); vertex(w, s/2 - w/2); vertex(s*(3.0/4.0), s/2 - w/2); vertex(s*(3.0/4.0), s/2 + w/2); vertex(w, s/2 + w/2); vertex(w, s-w); vertex(s, s-w); vertex(s, s); vertex(0,s); endShape(CLOSE); popMatrix(); // FFFFFFFFFFFFFF pushMatrix(); translate( smargin*0,smargin*1 ); beginShape(); vertex(0, 0); vertex(s, 0); vertex(s, w); vertex(w, w); vertex(w, s/2 - w/2); vertex(s*(3.0/4.0), s/2 - w/2); vertex(s*(3.0/4.0), s/2 + w/2); vertex(w, s/2 + w/2); vertex(w, s); vertex(0,s); endShape(CLOSE); popMatrix(); // GGGGGGGGGGGG pushMatrix(); fill(lightBlue); translate( smargin*1,smargin*1 ); float gmax = max(w*2,s/4); beginShape(); vertex(s-gmax, s/2-w/2); vertex(s, s/2-w/2); vertex(s, s/2); vertex(s-w/2, s/2+w/2); vertex(s-gmax, s/2+w/2); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s/2, s/2, s/2 - w/2, s/2 - w/2, 0, (7.0/4.0)*PI); strokeWeight(1); fill(lightBlue); popMatrix(); // H H H H H H H H H H H H HH H H H H HH pushMatrix(); translate( smargin*2,smargin*1 ); beginShape(); vertex(0, 0); vertex(w, 0); vertex(w, s/2-w/2); vertex(s-w, s/2-w/2); vertex(s-w, 0); vertex(s, 0); vertex(s, s); vertex(s-w, s); vertex(s-w, s/2+w/2); vertex(w, s/2+w/2); vertex(w, s); vertex(0, s); endShape(CLOSE); popMatrix(); // IIIIIIIIIIIIIIIIIIIIIIIIIIIII pushMatrix(); translate( smargin*3,smargin*1 ); beginShape(); vertex(s/2-w/2, 0); vertex(s/2+w/2, 0); vertex(s/2+w/2, s); vertex(s/2-w/2, s); endShape(CLOSE); popMatrix(); // JJJJJJJJJJJJJJJJJJJJJJJ pushMatrix(); fill(lightBlue); translate( smargin*4,smargin*1 ); beginShape(); vertex(s-w, 0); vertex(s, 0); vertex(s, s/2); vertex(s-w, s/2); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s/2, s/2, s/2 - w/2, s/2 - w/2, 0, PI); strokeWeight(1); fill(lightBlue); popMatrix(); // K K K K K K KK K K KK K K K K KK K K pushMatrix(); translate( smargin*0,smargin*2 ); beginShape(); vertex(0, 0); vertex(w, 0); vertex(w, a); vertex(w+a, 0); vertex(s, 0); vertex(s/2, s/2); vertex(s, s); vertex(w+a, s); vertex(s/2-w*sqrt(2)/2, s/2+w*sqrt(2)/2); vertex(w, s-w); vertex(w, s); vertex(0, s); endShape(CLOSE); popMatrix(); // L L L L LL L L L L LL L LLLLL pushMatrix(); translate( smargin*1,smargin*2 ); beginShape(); vertex(0, 0); vertex(w, 0); vertex(w, s-w); vertex(s, s-w); vertex(s, s); vertex(0,s); endShape(CLOSE); popMatrix(); // MMMMMMMMMMMMMMMMMMMMMM pushMatrix(); float Mcap = s*(4.0/3); fill(lightBlue); translate( smargin*2,smargin*2 ); beginShape(); vertex(0, 0); if ( (s-w*sqrt(2))*2 < Mcap ) { vertex( s-w*sqrt(2) , s-w*sqrt(2)); vertex( (s-w*sqrt(2))*2 , 0 ); vertex( (s-w*sqrt(2))*2 , s); vertex( (s-w*sqrt(2))*2 - w , s); vertex( (s-w*sqrt(2))*2 - w , s-a); vertex( s-w*sqrt(2) , s); } else { vertex( Mcap/2, Mcap/2 ); vertex( Mcap , 0 ); vertex( Mcap , s ); vertex( Mcap-w , s ); vertex( Mcap-w , s-a ); vertex( Mcap/2, Mcap/2+w*sqrt(2) ); } vertex(w, s-a); vertex(w, s); vertex(0,s); endShape(CLOSE); popMatrix(); // NNNNNNNNNNNNNNNNNNNNN pushMatrix(); fill(lightBlue); translate( smargin*4,smargin*2 ); beginShape(); vertex(0, 0); vertex(s-w, n); vertex(s-w, 0); vertex(s,0); vertex(s,s); vertex(w, s-n); vertex(w, s); vertex(0,s); endShape(CLOSE); popMatrix(); // OOOO O O O O O O O O OO OOO pushMatrix(); translate( (s+margin)*0,(s+margin)*3 ); strokeWeight(w); stroke(lightBlue); noFill(); arc(s/2, s/2, s/2 - w/2, s/2 - w/2, 0, 2*PI); strokeWeight(1); fill(lightBlue); popMatrix(); // PPPPPPP pushMatrix(); fill(lightBlue); translate( smargin*1,smargin*3 ); beginShape(); vertex(0, 0); vertex(s-b+1, 0); vertex(s-b+1, w); vertex(w, w); vertex(w, s/2 - w/2); vertex(s-b+1, s/2 - w/2); vertex(s-b+1, s/2 + w/2); vertex(w, s/2 + w/2); vertex(w, s); vertex(0,s); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s-b, b, b - w/2, b - w/2, -PI/2, PI/2); strokeWeight(1); fill(lightBlue); popMatrix(); // Q Q Q Q QQ Q Q Q QQ Q Q Q QQ Q pushMatrix(); translate( (s+margin)*2,(s+margin)*3 ); beginShape(); vertex(r, s/2); vertex(s-r, s/2); vertex(s, s); vertex(x,s); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s/2, s/2, s/2 - w/2, s/2 - w/2, 0, 2*PI); strokeWeight(1); fill(lightBlue); popMatrix(); // RR R R R R RR R R R RR R R R RR pushMatrix(); fill(lightBlue); translate( smargin*3,smargin*3 ); beginShape(); vertex(0, 0); vertex(s-b+1, 0); vertex(s-b+1, w); vertex(w, w); vertex(w, s/2 - w/2); vertex(s-b+1, s/2 - w/2); vertex(s-b+1, s/2 + w/2); vertex(w, s/2 + w/2); vertex(w, s); vertex(0,s); endShape(CLOSE); beginShape(); vertex(r, s/2); vertex(s-r, s/2); vertex(s, s); vertex(x,s); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s-b, b, b - w/2, b - w/2, -PI/2, PI/2); strokeWeight(1); fill(lightBlue); popMatrix(); // SS S S S S S S S SS S SS S S S S S pushMatrix(); fill(lightBlue); translate( smargin*4,smargin*3 ); strokeWeight(w); stroke(lightBlue); noFill(); float ax = s/2; float ay = w + ( (s/2) - (w + w/2) ) /2; float awidth = (s-w)/2; float aheight = ( s/2 - w/2) /2; float abegin = PI/2; float aend = 2*PI; arc(ax, ay, awidth, aheight, abegin, aend); ay = s - (w + ( (s/2) - (w + w/2) ) /2); abegin = -PI/2; aend = PI; arc(ax, ay, awidth, aheight, abegin, aend); strokeWeight(1); fill(lightBlue); popMatrix(); // T T T T T T T T T T T T T T T T T T T pushMatrix(); translate( (s+margin)*0,(s+margin)*4 ); beginShape(); vertex(0, 0); vertex(s, 0); vertex(s, w); vertex(s/2+w/2, w); vertex(s/2+w/2, s); vertex(s/2-w/2, s); vertex(s/2-w/2, w); vertex(0, w); endShape(CLOSE); popMatrix(); // UUUUUUUUUUUUUUUUUUUUUUUUUU pushMatrix(); fill(lightBlue); translate( smargin*1,smargin*4 ); beginShape(); vertex(0, 0); vertex(w, 0); vertex(w, s/2); vertex(0, s/2); endShape(CLOSE); beginShape(); vertex(s-w, 0); vertex(s, 0); vertex(s, s/2); vertex(s-w, s/2); endShape(CLOSE); strokeWeight(w); stroke(lightBlue); noFill(); arc(s/2, s/2, s/2 - w/2, s/2 - w/2, 0, PI); strokeWeight(1); fill(lightBlue); popMatrix(); // V V V V V V V V V V VV V V V pushMatrix(); translate( (s+margin)*2,(s+margin)*4 ); beginShape(); vertex(0, 0); vertex(w, 0); vertex(w, a); vertex(s-w*sqrt(2),0); vertex(s,0); vertex( 0, s); endShape(CLOSE); popMatrix(); // W W W W W W W W W W W W W W W W W W W W W pushMatrix(); float Wcap = s*(3/2.0); translate( (s+margin)*3,(s+margin)*4 ); beginShape(); vertex(0, 0); vertex(w, 0); vertex(w, a); if ( (s-w*sqrt(2))*2-w+w*sqrt(2) < Wcap ) { vertex(s-w*sqrt(2),0); vertex(s-w*sqrt(2),a); vertex( (s-w*sqrt(2))*2-w, 0 ); vertex( (s-w*sqrt(2))*2-w+w*sqrt(2), 0 ); vertex( s-w*sqrt(2)-w, s); vertex( s-w*sqrt(2)-w, s-a); } else { vertex(Wcap-s+w, s-((Wcap-s)+w+w*sqrt(2)) ); vertex(Wcap-s+w, a ); vertex(Wcap-w*sqrt(2), 0 ); vertex(Wcap, 0 ); vertex(Wcap-s, s); vertex(Wcap-s, s-(Wcap-s)); } vertex( 0, s); endShape(CLOSE); popMatrix(); // XXXXXXXXXXXXXXXXXXXXXX pushMatrix(); translate( (s+margin)*1,(s+margin)*5 ); beginShape(); vertex(0, 0); vertex(s-x, 0); vertex(s, s); vertex(x,s); endShape(CLOSE); beginShape(); vertex(x, 0); vertex(s, 0); vertex(s-x,s); vertex(0,s); endShape(CLOSE); popMatrix(); // Y Y Y Y YY Y Y Y YY pushMatrix(); translate( (s+margin)*2,(s+margin)*5 ); beginShape(); vertex(s-w*sqrt(2),0); vertex(s, 0); vertex(0, s); vertex(0, s-w*sqrt(2)); vertex( (s-w*sqrt(2))/2 - w/2 , (s-w*sqrt(2))/2 + w/2 ); vertex( (s-w*sqrt(2))/2 - w/2 , 0 ); vertex( (s-w*sqrt(2))/2 + w/2 , 0 ); vertex( (s-w*sqrt(2))/2 + w/2 , (s-w*sqrt(2))/2 - w/2 ); endShape(CLOSE); popMatrix(); // ZZZZ Z Z Z Z ZZ Z Z Z Z Z ZZ Z ZZZZZZ pushMatrix(); translate( (s+margin)*3,(s+margin)*5 ); beginShape(); vertex(0, 0); vertex(s, 0); vertex(s-n, s-w); vertex(s, s-w); vertex(s, s); vertex(0, s); vertex(n, w); vertex(0, w); endShape(CLOSE); popMatrix(); translate(-margin, -margin); } // GUI, so you can't click and drag on to other GUI elements void mouseReleased() { inputSelect = 0; } class Button { int selectThis, xpos, ypos, bsize, value, selected; Button (int st, int x, int y, int s, int v) { selectThis = st; xpos = x; ypos = y; bsize = s; value = v; } boolean hover() { return mouseX >= xpos && mouseX <= xpos+bsize && mouseY >= ypos && mouseY <= ypos+bsize ; } boolean pressed () { return hover() && mousePressed && inputSelect == 0 ; } void display () { if ( pressed() ) { inputSelect = selectThis; select = value; } if ( select == value ) { fill(250); } else { if ( hover() && inputSelect == 0 ) { fill(150); } else {fill(100); } } stroke(0); rectMode(CORNER); rect(xpos,ypos,bsize,bsize); } } class HSlider{ int selectThis, xpos, ypos, slength, swidth; float value, valuePos; boolean hover; HSlider (int st, int x, int y, int l, int w, float v) { selectThis = st; xpos = x; ypos = y; slength = l; swidth = w; value = v; } boolean hover() { return mouseX >= xpos && mouseX <= xpos+slength && mouseY >= ypos && mouseY <= ypos+swidth ; } void display () { if ( hover() && mousePressed && inputSelect == 0) { inputSelect = selectThis; } if ( inputSelect == selectThis ) { value = max( 0, min( 1, (mouseX-xpos)/float(slength) ) ); } if ( ( hover() && inputSelect == 0) || inputSelect == selectThis ) { stroke(darkBlue); } else { stroke(lightBlue); } valuePos = (value)*slength+xpos; strokeWeight(1); rectMode(CORNER); fill(240,240,255); rect(xpos,ypos,slength,swidth); strokeWeight(3); line(valuePos,ypos-3,valuePos,ypos+swidth+3); strokeWeight(1); line(valuePos,ypos-3,valuePos,ypos+swidth+3); } float value() {return value;} }