So all credit to him(or her).
I made it resizable pinned to width. I might upload some more effective code here in the future if i
think of one.
Code: Select all
int cx = 400, cy = 300, width = 400;// cx and cy are center coordinates
double inc = 1; // triangle steepness counter
for (int x = 0; x <= width/8.0; x++) //top of the crown
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + x - width/8.0, cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx + x - width/4.0, cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx + x - width*3/8.0, cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx + x - width/2.0, cy - y - width*7/16.0, 0, 255, 0);//first triangle spike from left
gfx.PutPixel(cx - x + width / 8.0, cy - y - width*7/16.0, 0, 255, 0); //right side mirrored cause of -x
gfx.PutPixel(cx - x + width / 4.0 , cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx - x + width * 3/8.0, cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx - x + width / 2.0, cy - y - width*7/16.0, 0, 255, 0);
}
inc = inc + 2; //triangles are 2 times higher than wide
}
for (int x = 0; x <= width; x++) { // base of the crown (green rectangle)
for (int y = 0; y <= width/8.0; y++) {
gfx.PutPixel(cx + x - width/2.0, cy + y - width*7/16.0, 0, 255, 0);
}
}
for (int x = 0; x <= width; x++) {//middle of face (white rectangle)
for (int y = 0; y <= width/2.0; y++) {
gfx.PutPixel(cx + x - width/2.0, cy + y - width*5/16.0, 255, 255, 255);
}
}
inc = 1;
for (int x = 0; x <= width/2.0; x++) // white triangle chin
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + x - width/2.0, cy + y+width*3/16.0, 255, 255, 255); //left side
gfx.PutPixel(cx - x + width/2.0, cy + y+ width *3/16.0, 255, 255, 255);//right side
}
inc = inc + 0.85;
}
for (int x = 0; x <= width/4.0; x++) { //black rectangle eyes
for (int y = 0; y < width/10.0; y++) {
gfx.PutPixel(cx + x + width/16.0, cy + y - width/8.0, 0, 0, 0); // right eye
gfx.PutPixel(cx - x - width/16.0, cy + y - width/8.0, 0, 0, 0); //left eye
}
}
for (int x = 0; x <= width/20.0; x++) { //black rectangle beard
for (int y = 0; y <= width*6/25.0; y++) {
gfx.PutPixel(cx + x -width/40.0, cy + y + width*3/8.0, 0, 0, 0);
}
}
for (int x = 1; x <= width*7/20; x++) { // black eyebrows
for (int y = 1; y < width/16.0; y++) {
gfx.PutPixel(cx + x - width*3/8.0, cy + y - width * 9/40.0, 0, 0, 0); // left eyebrow
gfx.PutPixel(cx + x + width/40.0, cy + y - width*9/40.0, 0, 0, 0); //right eyebrow
}
}
for (int x = 0; x <= width/2.0; x++) { // beige lips
for (int y = 0; y <= width/20.0; y++) {
gfx.PutPixel(cx + x - width/4.0, cy + y + width*5/16.0, 255, 220, 220);
}
}
inc = 1;
for (int x = 0; x <= width*3/16.0; x++) //beige cheeks
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + x - width/2.0, cy + y+width*3/16.0, 255, 240, 240); //left cheek
gfx.PutPixel(cx - x + width/2.0, cy + y+ width * 3 / 16.0, 255, 240, 240); // right cheek
}
inc = inc + 0.85;
}
inc = 1;
for (int x = 1; x <= width*5/16.0; x++)//beige nose - nose height
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + y, cy + x-width/8.0, 255, 240, 240);//right side
gfx.PutPixel(cx - y, cy + x-width/8.0, 255, 240, 240);//left side
}
inc = inc + 0.5;
}
for (int x = 0; x <= width/4.0; x++) { //black moustache-squares
for (int y = 1; y < width*3/80.0; y++) {
gfx.PutPixel(cx + x - width*5/16.0, cy + y + width/4.0, 0, 0, 0);
gfx.PutPixel(cx + x + width/16.0, cy + y + width/4.0, 0, 0, 0);
}
}
inc = 1;
for (int x = 0; x <= width/10.0; x++)//black moustache triangles
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + y + width/40.0, cy + x+ width * 3 / 16.0, 0, 0, 0);
gfx.PutPixel(cx - y - width/40.0, cy + x+ width * 3 / 16.0, 0, 0, 0);
}
inc = inc + 0.85;
}