
import java.io.*;

public class PaintSkin
{
	FileOutputStream	fos;
	int					mx,my,rad;
	int					re,ge,be,ro,go,bo,ri,gi,bi,rj,gj,bj;
	int					bmpWidth;
	int					bmpHeight;
	int					radius;
	int					inLen1;
	int					outLen;
	int					c1,c2,c3,c4,c5,c6,c7,c8,cA,cB,cC,cD,cE,cF;
	int					rl,gl,bl;
	int					skinColor;
	boolean				bTransparentBorder;
	boolean				bTransparentIn;
	byte[]				inBuf1;
	byte[]				outBuf;


	public PaintSkin() {
		radius     = 100; 		//[50..100%]
		skinColor  = 1;			//0=black  1=blue
	}

	public static void main (String argv []) {
		PaintSkin app = new PaintSkin();
		if (argv.length == 1) {
			if (argv[0].equals("0")) app.skinColor = 0;		//black
			if (argv[0].equals("1")) app.skinColor = 1;		//blue
		}
		app.makeSkin();
	}

	public void makeSkin() {
		if (skinColor == 0) {
			c1 = RGB(105,140,150);		//black skin
			c2 = RGB( 75,105,120);
			c3 = RGB( 22, 45, 49);		//mitte
			c4 = RGB( 15, 30, 42);
			c5 = RGB(  0,  8,  8);
			c6 = RGB(  0,  0,  0);
			c7 = RGB( 41, 83, 86);		//unten
			c8 = RGB( 25, 60, 70);
			cA = RGB( 80,104,128);
			cB = RGB( 64, 88,112);
			cC = RGB( 80,104,128);
			cD = RGB(238,  0,238);
			cE = RGB(125,160,170);		//oben
			cF = RGB( 95,125,140);
			rl = 50;	gl = 150;	bl = 250;		//cyan-blue hilight
			ro = 16;	go = 24;	bo = 32;		//MarginCol=02,03,04  (3PG.c04)
			ri = 32; 	gi = 40;	bi = 48;		//BackCol=04,05,06
		} else if (skinColor == 1) {
			c1 = RGB( 96,144,224);			//blue skin
			c3 = RGB(  0, 48,144);
			c5 = RGB(  0, 32, 96);
			c7 = RGB(  0, 90,180);
			cA = RGB( 45, 90,180);
			cD = RGB(238,  0,238);			//transparent
			cE = RGB(116,164,244);
			c2 = RGBP( c1, 85);				//85%
			c4 = RGBP( c3, 85);
			c6 = RGBP( c5, 85);
			c8 = RGBP( c7, 85);
			cB = RGBP( cA, 85);
			cC = RGBP( cA,100);
			cF = RGBP( cE, 85);
			rl = 60;	gl = 170;	bl = 240;		//cyan-blue hilight
			ro = 0;		go = 24;	bo = 64;		//MarginCol=00,03,08  (3PG.c03)
			ri = 0; 	gi = 40;	bi = 80;		//BackCol=00,05,10
		}
		makeInfobox("3PG-infobox.bmp");
		makeVolume("3PG-volume.bmp");
		makeMiniG1("3PG-mini.bmp");
		makeMsgbox("3PG-msgbox.bmp");
		makeProgress1("3PG-progress1.bmp");
		makeProgress2("3PG-progress2.bmp");
		makeWindow("3PG-window.bmp");
		makeCursor("3PG-cursor.bmp");
	}

	public void makeInfobox( String outFileName ) {
		int x,y,w,h;
		bmpWidth  = 720;
		bmpHeight = 128;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		y=60;
		h=118-y;
		w=120;
		for (x=0; x<bmpWidth; x+=w+w) {
			gradientColor(x,   4, w, y-4, c1,c2,c3,c4);
			gradientColor(x+w, 4, w, y-4, c2,c1,c4,c3);
			gradientColor(x,   y, w, h,   c5,c6,c7,c8);
			gradientColor(x+w, y, w, h,   c6,c5,c8,c7);
		}
		bTransparentBorder = true;
		bTransparentIn = true;
		roundRect3( 38,  4, 691, 116, 5600, 600 );
		roundRect2(168, 38, 675, 108, 3500, 300, 0,  0 );
		roundRect2(530, 71, 661, 102, 1600, 200, 9, 25 );
		gradientColor( 0, 0, 720, 4, cD,cD,cD,cD);	//transparent
		saveBitmap(outFileName);
	}

	public void makeWindow( String outFileName ) {
		int y,w,h,u,r,g,b;
		bmpWidth  = 160;
		bmpHeight = 160;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		y=25;
		h=35;
		w=80;
		u=160-33;
		gradientColor(0,   0,  60, y,  cE, cF, c3, c4);		//top
		gradientColor(60,  0,  40, y,  cF, cF, c4, c4);
		gradientColor(100, 0,  60, y,  cF, cE, c4, c3);
		gradientColor(0,   y,   w, h,  c5, c5, c6, c6);		//top
		gradientColor(w,   y,   w, h,  c5, c5, c6, c6);
		gradientColor(0,   60,  w, 40, c6, c6, c6, c6);		//middle
		gradientColor(w,   60,  w, 40, c6, c6, c6, c6);

		gradientColor(0,   100, 60, 15, c6, c6, c6, c6);	//bottom
		gradientColor(60,  100, 40, 15, c6, c6, c6, c6);
		gradientColor(100, 100, 60, 15, c6, c6, c6, c6);
		gradientColor(0,   115, 60, 36, c6, c6, cA, cB);	//bottom
		gradientColor(60,  115, 40, 36, c6, c6, cB, cB);
		gradientColor(100, 115, 60, 36, c6, c6, cB, cC);
		gradientColor(0,   150, 60, 10, cA, cB, c1, c1);	//bottom
		gradientColor(60,  150, 40, 10, cB, cB, c1, c1);
		gradientColor(100, 150, 60, 10, cB, cC, c1, c1);
		r=rl; g=gl; b=bl;
		rl=ro; gl=go; bl=bo;
		bTransparentBorder = false;
		bTransparentIn = false;
		roundRect3( 0,  0, 160, 160, 2500, 250 );
		roundRect2( 6, 36, 154, 124, 1400, 300, 0, 0 );
		rl=r; gl=g; bl=b;
		saveBitmap(outFileName);
	}

	public void makeCursor( String outFileName ) {
		int w,h,v,r,g,b;
		int f0,f1,f2,f3,f4,f5,f6,f7;
		bmpWidth  = 96;
		bmpHeight = 32;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		f0 = RGB(  8,  8,  8);
		f1 = RGB(  8, 16, 24);
		f2 = RGB( 16, 24, 32);
		f3 = RGB( 16, 28, 36);
		f4 = RGB(  0,190,220);
		f5 = RGB(  0,110,170);
		f6 = RGB( 60,120,240);
		f7 = RGB(200,200,255);
		gradientColor(0, 0, bmpWidth, bmpHeight, f0, f0, f0, f0);
		h=bmpHeight-5;
		v=6;
		gradientColor(  0, 0,   32,  h, f1,f2,f4,f5);
		gradientColor( 32, 0,   32,  h, f2,f2,f5,f5);
		gradientColor( 64, 0,   32,  h, f2,f1,f5,f6);
		gradientColor(  0, h-1, 32,  v, f4,f5,f7,f7);
		gradientColor( 32, h-1, 32,  v, f5,f5,f7,f7);
		gradientColor( 64, h-1, 32,  v, f5,f6,f7,f7);
		r=ro; g=go; b=bo;
		ro = (c6>>16)&255;
		go = (c6>> 8)&255;
		bo = c6&255;
		bTransparentBorder = false;
		roundRect3( 0,  0, bmpWidth, bmpHeight, bmpHeight*50, 200 );
		ro=r; go=g; bo=b;
		saveBitmap(outFileName);
	}

	public void makeMsgbox( String outFileName ) {
		int y;
		bmpWidth = 360;
		bmpHeight = 88;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		y=50;
		gradientColor(0,   0, 90, y,    c1,c2,c3,c4);
		gradientColor(90,  0, 90, y,    c2,c1,c4,c3);
		gradientColor(180, 0, 90, y,    c1,c2,c3,c4);
		gradientColor(270, 0, 90, y,    c2,c1,c4,c3);
		gradientColor(0,   y, 90, 87-y, c5,c6,c7,c8);
		gradientColor(90,  y, 90, 87-y, c6,c5,c8,c7);
		gradientColor(180, y, 90, 87-y, c5,c6,c7,c8);
		gradientColor(270, y, 90, 87-y, c6,c5,c8,c7);

		bTransparentIn = true;
		roundRect2(-20,32, 341, 78, 2200, 300, 0, 0 );
		roundRect1(  0, 0, 359, 87, 4300, 600 );
		saveBitmap(outFileName);
	}

	public void makeMiniG1( String outFileName ) {
		int y,w,h,r,g,b;
		bmpWidth  = 160;
		bmpHeight = 128;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		y=25;
		h=35;
		w=80;
		gradientColor(0,   0,  60, y,  cE, cF, c3, c4);		//top
		gradientColor(60,  0,  40, y,  cF, cF, c4, c4);
		gradientColor(100, 0,  60, y,  cF, cE, c4, c3);
		gradientColor(0,   y,   w, h,  c5, c5, c6, c6);		//middle
		gradientColor(w,   y,   w, h,  c5, c5, c6, c6);
		gradientColor(0,   60,  w, h,  c6, c6, c6, c6);
		gradientColor(w,   60,  w, h,  c6, c6, c6, c6);
		gradientColor(0,   95, 60, 33, c6, c6, cA, cB);		//bottom
		gradientColor(60,  95, 40, 33, c6, c6, cB, cB);
		gradientColor(100, 95, 60, 33, c6, c6, cB, cC);

		r=rl; g=gl; b=bl;
		rl=ro; gl=go; bl=bo;
		bTransparentBorder = true;
		bTransparentIn = false;
		roundRect3( 0,  0, 160, 128, 2500, 400 );
		roundRect2( 6, 36, 154, 120, 1400, 300, 0, 0 );
		rl=r; gl=g; bl=b;
		saveBitmap(outFileName);
	}

	public void makeProgress1( String outFileName ) {
		int co1,co2,co3,co4,co5,co6,co7,co8;
		bmpWidth  = 80;
		bmpHeight = 36;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		co1 = RGB( 32,144,200);
		co2 = RGB(  0, 80,200);
		co3 = RGB( 22, 45, 49);
		co4 = RGB( 15, 30, 42);
		co5 = RGB( 32,230,255);
		co6 = RGB( 16,144,210);
		co7 = RGB(  0,120,160);
		co8 = RGB(  0, 60,160);
		gradientColor(0,  0, 80, 18, co4, co4, co7, co7);		// Frame 100% (oben)
		gradientColor(0, 18, 80, 18, co4, co4, co7, co7);		// Frame 0% (unten)
		gradientColor(1,  1, 78,  8, co1, co2, co5, co6);		// 100%
		gradientColor(1,  9, 78,  8, co5, co6, co1, co2);		// 100%
		gradientColor(1, 19, 78,  8, co7, co8, co3, co4);		// 0%
		gradientColor(1, 27, 78,  8, co3, co4, co7, co8);		// 0%
		saveBitmap(outFileName);
	}

	public void makeProgress2( String outFileName ) {
		int co1,co2,co3,co4,co5,co6,co7,co8;
		bmpWidth  = 52;
		bmpHeight = 24;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		co1 = RGB( 32,144,200);
		co2 = RGB(  0, 80,200);
		co3 = RGB( 22, 45, 49);
		co4 = RGB( 15, 30, 42);
		co5 = RGB( 32,230,255);
		co6 = RGB( 16,144,210);
		co7 = RGB(  0,120,160);
		co8 = RGB(  0, 60,160);
		gradientColor(0,  0, 52, 12, co4, co4, co7, co7);		// Frame 100% (oben)
		gradientColor(0, 12, 52, 12, co4, co4, co7, co7);		// Frame 0% (unten)
		gradientColor(1,  1, 50,  5, co1, co2, co5, co6);		// 100%
		gradientColor(1,  6, 50,  5, co5, co6, co1, co2);		// 100%
		gradientColor(1, 13, 50,  5, co7, co8, co3, co4);		// 0%
		gradientColor(1, 18, 50,  5, co3, co4, co7, co8);		// 0%
		saveBitmap(outFileName);
	}

	public void makeVolume( String outFileName ) {
		int w,h;
		bmpWidth = 280;
		bmpHeight = 50;
		outLen = bmpWidth*bmpHeight*3+54;
		outBuf = new byte[outLen];
		h=25;
		w=140;
		gradientColor(0, 0, w, h, c1,c2,c3,c4);
		gradientColor(w, 0, w, h, c2,c1,c4,c3);
		gradientColor(0, h, w, h, c5,c6,c7,c8);
		gradientColor(w, h, w, h, c6,c5,c8,c7);

		bTransparentIn = true;
		roundRect1( 2, 1, 277, 45, 2200, 600 );
		roundRect2(44,10, 271, 42, 1600, 300, 0, 0 );
		saveBitmap(outFileName);
	}

	public void saveBitmap( String fname ) {
		int i,hdrlen,flen,dlen,color;
		for (i=0; i<54; i++) outBuf[i] = 0;
		hdrlen = 0x36;
		flen   = bmpWidth*bmpHeight*3 + 54;
		dlen   = bmpWidth*bmpHeight*3;
		color  = 0x180001;
		outBuf[ 0] = 0x42;
		outBuf[ 1] = 0x4D;
		outBuf[ 2] = (byte)(flen & 0xFF);
		outBuf[ 3] = (byte)((flen >> 8) & 0xFF);
		outBuf[ 4] = (byte)((flen >> 16) & 0xFF);
		outBuf[ 5] = (byte)((flen >> 24) & 0xFF);
		outBuf[10] = (byte)(hdrlen & 0xFF);
		outBuf[11] = (byte)((hdrlen >> 8) & 0xFF);
		outBuf[12] = (byte)((hdrlen >> 16) & 0xFF);
		outBuf[13] = (byte)((hdrlen >> 24) & 0xFF);
		outBuf[14] = 0x28;
		outBuf[18] = (byte)(bmpWidth & 0xFF);
		outBuf[19] = (byte)((bmpWidth >> 8) & 0xFF);
		outBuf[20] = (byte)((bmpWidth >> 16) & 0xFF);
		outBuf[21] = (byte)((bmpWidth >> 24) & 0xFF);
		outBuf[22] = (byte)(bmpHeight & 0xFF);
		outBuf[23] = (byte)((bmpHeight >> 8) & 0xFF);
		outBuf[24] = (byte)((bmpHeight >> 16) & 0xFF);
		outBuf[25] = (byte)((bmpHeight >> 24) & 0xFF);
		outBuf[26] = (byte)(color & 0xFF);
		outBuf[27] = (byte)((color >> 8) & 0xFF);
		outBuf[28] = (byte)((color >> 16) & 0xFF);
		outBuf[29] = (byte)((color >> 24) & 0xFF);
		outBuf[34] = (byte)(dlen & 0xFF);
		outBuf[35] = (byte)((dlen >> 8) & 0xFF);
		outBuf[36] = (byte)((dlen >> 16) & 0xFF);
		outBuf[37] = (byte)((dlen >> 24) & 0xFF);
		try {
			fos = new FileOutputStream(fname);
			fos.write(outBuf, 0, outLen);
			fos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	void gradientColor( int xo, int yo, int width, int height, int c1, int c2, int c3, int c4 ) {
		int xp,yp,idx;
		int r1,r2,r3,r4,rl,rr;
		int g1,g2,g3,g4,gl,gr;
		int b1,b2,b3,b4,bl,br;
		int rp,gp,bp,re,ge,be;
		int rt,gt,bt;
		int[] rf;
		int[] gf;
		int[] bf;

		rf = new int[722];
		gf = new int[722];
		bf = new int[722];
		r1 = ((c1 >> 16) & 0xFF)<<10;
		g1 = ((c1 >> 8) & 0xFF)<<10;
		b1 = (c1 & 0xFF)<<10;
		r2 = ((c2 >> 16) & 0xFF)<<10;
		g2 = ((c2 >> 8) & 0xFF)<<10;
		b2 = (c2 & 0xFF)<<10;
		r3 = ((c3 >> 16) & 0xFF)<<10;
		g3 = ((c3 >> 8) & 0xFF)<<10;
		b3 = (c3 & 0xFF)<<10;
		r4 = ((c4 >> 16) & 0xFF)<<10;
		g4 = ((c4 >> 8) & 0xFF)<<10;
		b4 = (c4 & 0xFF)<<10;
		for (xp=0; xp<width+2; xp++) {
			rf[xp] = 0;
			gf[xp] = 0;
			bf[xp] = 0;
		}
		for (yp=0; yp<height; yp++) {
			re = ge = be = 0;
			rl = r1+(yp*(r3-r1))/(height-1);
			rr = r2+(yp*(r4-r2))/(height-1);
			gl = g1+(yp*(g3-g1))/(height-1);
			gr = g2+(yp*(g4-g2))/(height-1);
			bl = b1+(yp*(b3-b1))/(height-1);
			br = b2+(yp*(b4-b2))/(height-1);
			for (xp=0; xp<width; xp++) {
				rp = rf[xp]+re+rl+(xp*(rr-rl))/(width-1);
				gp = gf[xp]+ge+gl+(xp*(gr-gl))/(width-1);
				bp = bf[xp]+be+bl+(xp*(br-bl))/(width-1);
				if (rp > 0x3FFFF) rp = 0x3FFFF;
				if (gp > 0x3FFFF) gp = 0x3FFFF;
				if (bp > 0x3FFFF) bp = 0x3FFFF;
				idx = (xo+xp+(bmpHeight-yo-yp-1)*bmpWidth)*3+54;
				outBuf[idx]   = (byte)((bp >> 10) & 255);
				outBuf[idx+1] = (byte)((gp >> 10) & 255);
				outBuf[idx+2] = (byte)((rp >> 10) & 255);
				rt = rp & 1023;
				gt = gp & 1023;
				bt = bp & 1023;
				re = (rt*7)>>4;		//Floyd-Steinberg-Dither
				ge = (gt*7)>>4;		//   0     X   7/16
				be = (bt*7)>>4;		// 3/16  5/16  1/16
				if (xp > 0) {
					rf[xp-1] += (rt*3)>>4;
					gf[xp-1] += (gt*3)>>4;
					bf[xp-1] += (bt*3)>>4;
				}
				rf[xp] = (rt*5)>>4;
				gf[xp] = (gt*5)>>4;
				bf[xp] = (bt*5)>>4;
				rf[xp+1] += rt>>4;
				gf[xp+1] += gt>>4;
				bf[xp+1] += bt>>4;
			}
		}
	}

	int RGB( int r, int g, int b ) {
		return (r<<16)|(g<<8)|b;
	}

	int RGBP( int col, int percent ) {
		int r = (((col>>16)&255)*percent)/100;
		int g = (((col>> 8)&255)*percent)/100;
		int b = ((col&255)*percent)/100;
		if (r > 255) r = 255;
		if (g > 255) g = 255;
		if (b > 255) b = 255;
		return (r<<16)|(g<<8)|b;
	}

	public void setPixel( int x, int y, int r, int g, int b ) {
		int ofs;
		if (b < 0) b=0;
		if (g < 0) g=0;
		if (r < 0) r=0;
		if (b > 255) b=255;
		if (g > 255) g=255;
		if (r > 255) r=255;
		ofs = (x+(bmpHeight-y-1)*bmpWidth)*3+54;
		outBuf[ofs]   = (byte)b;
		outBuf[ofs+1] = (byte)g;
		outBuf[ofs+2] = (byte)r;
	}

	public int getByte( int index ) {
		if (index >= inLen1) return 0;
		return ((int)inBuf1[index]) & 255;
	}

	public int getWinkel( int x, int y, int da ) {
		int aa;

		aa = (int)(Math.asin(((y-my)*100.0)/rad)*180.0/Math.PI);
		if (y > my) {
			if (x > mx) aa = 180-aa;
		} else {
			if (x > mx) aa = -180-aa;
		}
		aa += da;
		if (aa < 0) aa = -aa;
		if (aa > 180) aa = 360-aa;
		if (aa > 150) aa = 180;
		else if (aa < 45) aa = 45;
		else aa = 45 + (((aa-45)*135)/105);		//0..105 -> 0..135
		return aa;
	}

	public void setBackgroundColor( int x, int y ) {
		int idx;
		if (y < 0) y=0;
		idx = (x+(bmpHeight-y-1)*bmpWidth)*3+54;
		be = ((int)outBuf[idx]) & 255;
		ge = ((int)outBuf[idx+1]) & 255;
		re = ((int)outBuf[idx+2]) & 255;
		if (bTransparentIn) {
			bj = be;
			gj = ge;
			rj = re;
		}
	}

	public void roundRect1( int bx1, int by1, int bx4, int by4, int rmax, int drad ) {
		int r,g,b,x,y,xp,yp,r1,r2,rmin,rmid,aa;
		int rw,gw,bw,bx2,by2,bx3,by3;

		mx = (bx4-bx1)/2;
		my = (by4-by1)/2;
		rmax = (rmax*radius)/100;
		rmid = rmax;
		rmin = rmax-drad;
		bx2 = bx1+(rmax/100);
		by2 = by1+(rmax/100);
		bx3 = bx4-(rmax/100);
		by3 = by4-(rmax/100);

		for (y=0; y<bmpHeight; y++) {
			for (x=0; x<bmpWidth; x++) {
				xp = x;
				yp = y;
				if (x >= bx2 && x < bx3) xp = mx;
				if (x < bx2) xp = x+mx-bx2;
				if (x >= bx3) xp = x-bx3+mx;
				if (y >= by2 && y < by3) yp = my;
				if (y < by2) yp = y+my-by2;
				if (y >= by3) yp = y-by3+my;
				setBackgroundColor(x,y);
				rad = (int)(Math.sqrt((xp-mx)*(xp-mx)+(yp-my)*(yp-my))*100.0);
				if (rad >= rmax) {
					r=238; g=0; b=238;		//transparent
				} else if (rad >= rmid && rad < rmax) {
					aa = getWinkel(xp,yp,45); //-135);
					bw = (bl*aa)/180;
					gw = (gl*aa)/180;
					rw = (rl*aa)/180;
					r1 = rad-rmid;
					r2 = rmax-rmid;
					b = bw + ((-bw)*r1)/r2;
					g = gw + ((-gw)*r1)/r2;
					r = rw + ((-rw)*r1)/r2;

				} else if (rad >= rmin && rad < rmid) {
					aa = getWinkel(xp,yp,45); //-135);
					bw = (bl*aa)/180;
					gw = (gl*aa)/180;
					rw = (rl*aa)/180;
					r1 = rad-rmin;
					r2 = rmid-rmin;
					b = be + ((bw-be)*r1)/r2;
					g = ge + ((gw-ge)*r1)/r2;
					r = re + ((rw-re)*r1)/r2;
				} else {
					b = be;
					g = ge;
					r = re;
				}
				setPixel( x, y, r, g, b );
			}
		}
	}

	public void roundRect2( int bx1, int by1, int bx4, int by4, int rmax, int drad, int bgxo, int bgyo ) {
		int r,g,b,x,y,xp,yp,r1,r2,rmin,rmid,aa;
		int rw,gw,bw,bx2,by2,bx3,by3;

		mx = (bx4-bx1)/2;
		my = (by4-by1)/2;
		rmax = (rmax*radius)/100;
		rmid = rmax-drad;
		rmin = rmid-drad;
		bx2 = bx1+(rmax/100);
		by2 = by1+(rmax/100);
		bx3 = bx4-(rmax/100);
		by3 = by4-(rmax/100);
		rj=ri; gj=gi; bj=bi;
		for (y=0; y<bmpHeight; y++) {
			for (x=0; x<bmpWidth; x++) {
				xp = x;
				yp = y;
				if (x >= bx2 && x < bx3) xp = mx;
				if (x < bx2) xp = x+mx-bx2;
				if (x >= bx3) xp = x-bx3+mx;
				if (y >= by2 && y < by3) yp = my;
				if (y < by2) yp = y+my-by2;
				if (y >= by3) yp = y-by3+my;
				setBackgroundColor(x-bgxo,y-bgyo);
				rad = (int)(Math.sqrt((xp-mx)*(xp-mx)+(yp-my)*(yp-my))*100.0);
				if (rad < rmax) {
					aa = getWinkel(xp,yp,45);
					bw = (bl*aa)/180;
					gw = (gl*aa)/180;
					rw = (rl*aa)/180;
					if (rad >= rmin && rad < rmid) {
						r1 = rad-rmin;
						r2 = rmid-rmin;
						b = bj + ((bw-bj)*r1)/r2;
						g = gj + ((gw-gj)*r1)/r2;
						r = rj + ((rw-rj)*r1)/r2;
					} else if (rad >= rmid && rad < rmax) {
						r1 = rad-rmid;
						r2 = rmax-rmid;
						setBackgroundColor(x,y);
						b = bw + ((be-bw)*r1)/r2;
						g = gw + ((ge-gw)*r1)/r2;
						r = rw + ((re-rw)*r1)/r2;
					} else {
						b = bj;
						g = gj;
						r = rj;
					}
					setPixel( x, y, r, g, b );
				}
			}
		}
	}

	public void roundRect3( int bx1, int by1, int bx4, int by4, int rmax, int drad ) {
		int r,g,b,x,y,xp,yp,r1,r2,rmin;
		int bx2,by2,bx3,by3;

		mx = (bx4-bx1)/2;
		my = (by4-by1)/2;
		rmax = (rmax*radius)/100;
		rmin = rmax-drad;
		bx2 = bx1+(rmax/100);
		by2 = by1+(rmax/100);
		bx3 = bx4-(rmax/100);
		by3 = by4-(rmax/100);

		for (y=0; y<bmpHeight; y++) {
			for (x=0; x<bmpWidth; x++) {
				xp = x;
				yp = y;
				if (x >= bx2 && x < bx3) xp = mx;
				if (x < bx2) xp = x+mx-bx2;
				if (x >= bx3) xp = x-bx3+mx;
				if (y >= by2 && y < by3) yp = my;
				if (y < by2) yp = y+my-by2;
				if (y >= by3) yp = y-by3+my;
				setBackgroundColor(x,y);
				rad = (int)(Math.sqrt((xp-mx)*(xp-mx)+(yp-my)*(yp-my))*100.0);
				if (rad >= rmax) {
					if (bTransparentBorder) {
						r = 0xEE;		//transparent
						g = 0x00;
						b = 0xEE;
					} else {
						r = ro;
						g = go;
						b = bo;
					}
				} else if (rad >= rmin && rad < rmax) {
					r1 = rad-rmin;
					r2 = rmax-rmin;
					b = be + ((bo-be)*r1)/r2;
					g = ge + ((go-ge)*r1)/r2;
					r = re + ((ro-re)*r1)/r2;
				} else {
					b = be;
					g = ge;
					r = re;
				}
				setPixel( x, y, r, g, b );
			}
		}
	}
}

