Flag Of Kenya
// Flag of Kenya - Jim Bumgardner
//
// Bezier curves transcribed from http://en.wikipedia.org/wiki/File:Flag_of_Kenya.svg
float kHeight = 332;
float kWidth = kHeight*3/2;
float kStripeHeight = kHeight * 24 / 80;
float kStripeGap = kHeight * 4 / 80;
void setup()
{
size(int(kWidth), int(kHeight));
smooth();
noLoop();
}
void draw()
{
float x,y;
background( #FFFFFF );
noStroke();
fill( #000000 );
rect(0,0,width, kStripeHeight);
// red stripe not necessary at this point
// fill( #bb0000 );
// rect(0,kStripeHeight+kStripeGap,width, kStripeHeight);
fill( #006600 );
rect(0,kStripeHeight*2+kStripeGap*2,width, kStripeHeight);
pushMatrix();
// Switch coordinate system to match SVG file (centered, 240x160)
translate(width/2, height/2);
scale(width/240.0);
fill( #ffffff );
stroke(0);
strokeWeight(.5/(width/240.0));
pushMatrix();
drawSpear();
scale(-1,1);
drawSpear();
popMatrix();
noStroke();
// Red shield and Stripe
fill( #bb0000 );
beginShape();
x = -120;
y = -24;
vertex(x,y);
y = 24; vertex(x,y);
x = -19; vertex(x,y);
bezierVertex(x+3,y+8, x+13,y+24, x+19,y+24); x += 19; y += 24;
bezierVertex(x+6,y, x+16,y-16,x+19,y-24); x += 19; y -= 24;
x = 120; vertex(x,y);
y = -24; vertex(x,y);
x = 19; vertex(x,y);
bezierVertex(x-3,y-8, x-13,y-24, x-19,y-24); x -= 19; y -= 24;
bezierVertex(x-6,y, x-16,y+16,x-19,y+24);
endShape(CLOSE);
// Black decoration
fill(0);
pushMatrix();
drawBlackDeco();
scale(-1,1);
drawBlackDeco();
popMatrix();
// White decoration
fill( #ffffff );
ellipse(0,0,4,6);
pushMatrix();
drawWhiteDeco();
scale(-1,1);
drawWhiteDeco();
scale(1,-1);
drawWhiteDeco();
scale(-1,1);
drawWhiteDeco();
popMatrix();
popMatrix();
}
void drawBlackDeco()
{
beginShape();
float x = 19;
float y = 24;
vertex(x,y);
bezierVertex(x+3,y-8, x+5,y-16, x+5,y-24); x += 5; y -= 24;
bezierVertex(x,y-8,x-2,y-16,x-5,y-24); x -= 5; y -= 24;
bezierVertex(x-3,y+8, x-5,y+16, x-5,y+24); x -= 5; y += 24;
bezierVertex(x,y+8,x+2,y+16,x+5,y+24);
endShape(CLOSE);
}
void drawWhiteDeco()
{
beginShape();
float x = 1;
float y = 5.85;
vertex(x,y);
bezierVertex(x,y,x+4,y+8,x+4,y+21); x += 4; y += 21;
bezierVertex(x,y+13,x-4,y+21,x-4,y+21);
endShape();
}
void drawSpear()
{
pushMatrix();
rotate(radians(30));
beginShape();
vertex(-1, 55.4256);
vertex(1,55.4256);
vertex(1,-38);
bezierVertex(3,-40, 3,-43, 3,-46);
bezierVertex(3,-48, 3,-56, 0,-64.6632);
bezierVertex(-3,-56, -3,-48, -3,-46);
bezierVertex(-3,-43, -3,-40, -1,-38);
endShape(CLOSE);
popMatrix();
}