// South Korea // Reference: http://en.wikipedia.org/wiki/Flag_of_South_Korea#Specifications int kHeight = 330; // The only number that needs changing size(kHeight*3/2, kHeight); noStroke(); smooth(); color blueColor = color(0x00,0x34,0x78); color whiteColor = color(255,255,255); color blackColor = color(0,0,0); color redColor = color(0xC6,0x0C,0x30); float circWidth = width/3; float triWidth = circWidth/2.0; float barHeight = circWidth/12.0; float barDist = circWidth/12.0 + circWidth/24.0; float triBase = circWidth/4.0; float rotAngle = atan2(height/2, width/2); // Background white field background(whiteColor); // Draw taegeuk figure pushMatrix(); translate(width/2, height/2); rotate(rotAngle); fill(redColor); arc(0,0,circWidth, circWidth, 0, TWO_PI); fill(blueColor); arc(0,0,circWidth, circWidth, 0, PI); ellipse(circWidth/4,0, circWidth/2, circWidth/2); fill(redColor); ellipse(-circWidth/4,0, circWidth/2, circWidth/2); popMatrix(); // Bit patterns on trigrams int[] trigrams = {0,5,7,2}; noStroke(); for (int t = 0; t < 4; ++t) { pushMatrix(); translate(width/2, height/2); switch (t) { case 0: rotate(rotAngle); break; case 1: rotate(PI-rotAngle); break; case 2: rotate(PI+rotAngle); break; case 3: rotate(-rotAngle); break; } for (int b = 0; b < 3; ++b) { float x1 = circWidth/2 + triBase + barDist*b; float y1= -circWidth/4; fill(blackColor); rect(x1,y1, barHeight, triWidth); if ((trigrams[t] & (1 << b)) == 0) { // white block fill(whiteColor); rect(x1-2,-circWidth/48, barHeight+4, circWidth/24); } } popMatrix(); }