resizable Chili-head

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
krautersuppe
Posts: 91
Joined: September 14th, 2015, 10:58 pm
Location: Istanbul

resizable Chili-head

Post by krautersuppe » April 11th, 2017, 2:25 pm

I took code from Legacy's homework: http://forum.planetchili.net/viewtopic.php?f=3&t=3890
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; 
		}
Hope you can use this making games where Chili munches poo , Chili in maze games and others :lol:
chili_drawing.png
(9.18 KiB) Not downloaded yet
DSU
Discord: dsu1, GitHub: https://github.com/DSpUz

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: resizable Chili-head

Post by chili » April 12th, 2017, 1:47 pm

Haha, this is pretty sweet :D Looks like it took quite some effort to pull off. Thanks for sharing bro!
Chili

Post Reply