// United Kingdom (Union Flag / Union Jack) - Jim Bumgardner // Reference: http://en.wikipedia.org/wiki/Union_Flag int kHeight = 250; // Flag will still draw correctly if height is changed. float aspectRatio = 2/1.0; // Flag will still draw correctly if aspect ratio is changed (try 3/2.0) size((int) (kHeight*aspectRatio), kHeight); noStroke(); smooth(); color blueColor = color(0,36,125); color whiteColor = color(255,255,255); color redColor = color(207,20,43); float fatRedCrossWidth= height/5.0; float thinRedCrossWidth = height/15.0; float whiteDiagonalCrossWidth = height/5.0; float fatWhiteCrossWidth = height/3.0; // Background blue field fill(blueColor); rect(0,0, width, height); // White Diagonal Cross (not too hard, because it's centered on corners) stroke(whiteColor); strokeCap(PROJECT); noFill(); strokeWeight(whiteDiagonalCrossWidth); line(0,0,width,height); line(0,height,width,0); // Thin Red Diagonal Lines (the most complicated bit, because each one is offset) // This is the ratio of the diagonal stripe's height on the y-axis to it's cross section float yRatio = 1/sin(radians(90)-atan2(height,width)); // This is the amount to move the (centered stripe) so it lines up with corner, creating pinwheel effect. float offsetY = thinRedCrossWidth*yRatio/2; stroke(redColor); strokeWeight(thinRedCrossWidth); line(0,0+offsetY,width/2,height/2+offsetY); // top left stripe line(width,0-offsetY,width/2,height/2-offsetY); // top right stripe line(width,height-offsetY,width/2,height/2-offsetY); // bot right stripe line(0,height+offsetY,width/2,height/2+offsetY); // bot left stripe strokeWeight(1); noStroke(); // Fat White Cross fill(whiteColor); rect(0,height/2-fatWhiteCrossWidth/2, width, fatWhiteCrossWidth); rect(width/2-fatWhiteCrossWidth/2,0, fatWhiteCrossWidth, height); // Fat Red Cross fill(redColor); rect(0,height/2-fatRedCrossWidth/2, width, fatRedCrossWidth); rect(width/2-fatRedCrossWidth/2,0, fatRedCrossWidth, height);