
import java.awt.*;


public class JoeyGraphics extends Object {
	
	Graphics g;
	
	public JoeyGraphics(Graphics g) { 
		this.g = g;
	}
	
	public void setColor(Color c) { 
		g.setColor(c);
	}


	public void drawIdLine(int id, int x1, int y1, int x2, int y2) {
		
		
		switch (id)	{
		case 0:
			drawParam0Line(x1, y1, x2, y2);
			break;
		case 1:
			drawLoopyLine(x1, y1, x2, y2);
			break;
		case 2:
			drawParam2Line(x1, y1, x2, y2);
			break;
		case 3:
			drawWebbedLine(x1, y1, x2, y2);
			break;
		case 4:
			drawParam4Line(x1, y1, x2, y2);
			break;
		case 5:
			drawParam5Line(x1, y1, x2, y2);
			break;
		case 6:
			drawParam6Line(x1, y1, x2, y2);
			break;
		case 7:
			drawSquaresLine(x1, y1, x2, y2);
			break;
		case 8:
			drawRectLine(x1, y1, x2, y2);
			break;
		case 9:
			drawParam9Line(x1, y1, x2, y2);
			break;
			
		default:
			g.drawLine(x1, y1, x2, y2);
		}	
		
	}

	
	public void drawRectLine(int x1, int y1, int x2, int y2) {

		for (int t=0; t<14; t=t+1) {	
		
			int Y = (int)(30*Math.cos((y1+x1)/100) + t*29 + (y1)%6) ;
			int H = (int)(10*Math.cos(x1/200) + (t+x1)%12);

			g.drawRect(((x1/20)*20), Y, 20, H);

		}

	}
	


	public void drawThickLine(int x1, int y1, int x2, int y2) {
		g.drawLine(x1-1, y1-1, x2-1, y2-1);
		g.drawLine(x1-1, y1+1, x2-1, y2+1);
		g.drawLine(x1+1, y1-1, x2+1, y2-1);
		g.drawLine(x1+1, y1+1, x2+1, y2+1);	
		
		g.drawLine(x1, y1+1, x2, y2+1);
		g.drawLine(x1, y1-1, x2, y2-1);
		g.drawLine(x1+1, y1, x2+1, y2);
		g.drawLine(x1-1, y1, x2-1, y2);
		
		g.drawLine(x1, y1+1, x2, y2-1);
		g.drawLine(x1, y1-1, x2, y2+1);
		g.drawLine(x1+1, y1, x2-1, y2);
		g.drawLine(x1-1, y1, x2+1, y2);
		
		g.drawLine(x1, y1, x2, y2);
	}
	
	public void drawHairyLine(int x1, int y1, int x2, int y2) {
		
		int tempy1 = (int)(35*Math.random()*Math.cos(3*Math.random()));
		int tempx1 = (int)(35*Math.random()*Math.cos(3*Math.random()));
		int tempy2 = (int)(35*Math.random()*Math.cos(3*Math.random()));
		int tempx2 = (int)(35*Math.random()*Math.cos(3*Math.random()));
		
		drawThickLine(x1, y1, x2+tempx1, y2+tempy1);
		drawThickLine(x1+tempx2, y1+tempy2, x2, y2);
		
	}
	


	public void drawThinHairyLine(int x1, int y1, int x2, int y2) {
		
		int tempy1 = (int)(20*Math.random()*Math.cos(3*Math.random()));
		int tempx1 = (int)(20*Math.random()*Math.cos(3*Math.random()));
		int tempy2 = (int)(20*Math.random()*Math.cos(3*Math.random()));
		int tempx2 = (int)(20*Math.random()*Math.cos(3*Math.random()));
		
		g.drawLine(x1, y1, x2+tempx1, y2+tempy1);
		g.drawLine(x1+tempx2, y1+tempy2, x2, y2);
	}
	
	
	public void drawBubblyLine(int x1, int y1, int x2, int y2) {

		int r1 = (int)(Math.random()*20);
			int r2 = (int)(Math.random()*50);
			int r3 = (int)(Math.random()*80);
			int r4 = (int)(Math.random()*120);
		
		g.drawOval((x1+x2)/2-r1/2, (y1+y2)/2-r1/2, r1, r1);
		g.drawOval((x1+x2)/2-r2/2, (y1+y2)/2-r2/2, r2, r2);
		g.drawOval((x1+x2)/2-r3/2, (y1+y2)/2-r3/2, r3, r3);
		g.drawOval((x1+x2)/2-r4/2, (y1+y2)/2-r4/2, r4, r4);
		
	}
	
	public void drawSlopeLine(int x1, int y1, int x2, int y2) {
		
		double dx = x2-x1;
		double dy = y2-y1;
		
		int tempy = (int)(dy/dx);
		int tempx = (int)(dx/dy);
		
		g.drawLine(x1, y1, x1+tempx, y1+tempy);
		//		g.drawLine(x1+tempx, y1+tempy, x2+tempx, y2+tempy);
		g.drawLine(x1+tempx, y1+tempy, x2, y2);
		
	}
	
	
	public void drawSquaresLine(int x1, int y1, int x2, int y2) {
		
		int xMax;
		int yMax;
		int xMin;
		int yMin;
		
		xMax = Math.max(x1, x2);
		if (xMax == x1) {yMax = y1; xMin = x2;  yMin = y2;}
		else { yMax = y2; xMin = x1; yMin = y1;}
		
		int ww = (xMax-xMin)/15;
		int hh = (yMax-yMin)/15;
		
		int slope;
		
		if (ww!=0) slope = hh/ww;
		else slope = hh/(ww+1);
		
		for(int i=-15; i<=15; i++) {    
			g.drawRect(i*ww+xMin+(int)(Math.random()*6), i*hh+yMin+(int)(Math.random()*6), (int)(Math.random()*7), (int)(Math.random()*7));      
        }
		
	}
	
	
	public void drawJaggedLine(int x1, int y1, int x2, int y2) {
		
	}

		
	public void drawWebbedLine(int x1, int y1, int x2, int y2) {

	
		for (int t=0; t<9; t=t+1) {	
			float s1 = (float)(t)/(float)3;
			float s2 = (float)(t+1)/(float)3;

			float X1 = (float) (3* Math.cos(s1) * Math.cos(s1));
			float Y1 = (float) (3* Math.cos(s1) * Math.sin(s1));
			float X2 = (float) (3* Math.cos(s2) * Math.cos(s2));
			float Y2 = (float) (3* Math.cos(s2) * Math.sin(s2));
			
			float tempx = x1 + (float)(x2-x1)*t/8;
			float tempy = y1 + (float)(y2-y1)*t/8;

			g.drawLine((int)(tempx+X1), (int)(tempy+Y1), (int)(tempx*X2), (int)(tempy*Y2));
		}
		
	}
	
	
		
	public void drawLoopyLine(int x1, int y1, int x2, int y2) {

		int xStep = (int) ( (float)(x2-x1)/(float)32 );
		int yStep = (int) ( (float)(y2-y1)/(float)32 );
		int big = (x1+3*y1)/4;
		
		for (int t=-6; t<37; t++) {	
			float s1 = (float)(t)/10;
			float s2 = (float)(t+1)/10;
			float X1 = (float) (big * Math.cos(3*s1) * Math.cos(2*s1));
			float Y1 = (float) (big * Math.cos(3*s1) * Math.sin(s1));
			float X2 = (float) (big * Math.cos(3*s2) * Math.cos(2*s2));
			float Y2 = (float) (big * Math.cos(3*s2) * Math.sin(s2));
	
			g.drawLine(200+(int)X1+t*xStep, 200+(int)Y1+t*yStep, 200+(int)X2+(t)*xStep, 200+(int)Y2+(t)*yStep);
		}
	}

	public void drawParam0Line(int x1, int y1, int x2, int y2) {

		double one = 1;
		double two = 1.3;

		for (int t=0; t<32; t=t+1) {

			int s = t+1;
			float tempx1 = (float)(x1*(10-t)+ x2*t) /(float)10;
			float tempy1 = (float)(y1*(10-t)+ y2*t) /(float)10;
			float tempx2 = (float)(x1*(10-s)+ x2*s) /(float)10;
			float tempy2 = (float)(y1*(10-s)+ y2*s) /(float)10;
			g.drawLine((int)(tempx1-two), (int)(tempy1+one), (int)(tempx2 - (one * 2 * Math.cos(t/10))), (int)(tempy2 + (two * 2 * Math.sin(t/10))));
			one = one * 2 * Math.cos(t/10);
			two = two * 2 * Math.sin(t/10);
		}
	}

	
	public void drawParam1Line(int x1, int y1, int x2, int y2) {
		
	
	
			float X1 = (float) (50 * Math.cos(x1) * Math.cos(x1));	

			g.drawLine((int)x1, 0, (int)(x1+X1), 400);
		
		
	}
	

	


	public void drawParam2Line(int x1, int y1, int x2, int y2) {

				
		int big = y1*200/x1;

		for (int t=0; t<314; t=t+10) {	
			float s1 = (float)(t)/(float)100;
			float s2 = (float)(t+2)/(float)100;

			float X1 = (float) ((50+big)* Math.cos(s1) * Math.cos(s1));
			float Y1 = (float) ((50+big)* Math.cos(s1) * Math.sin(s1));
			float X2 = (float) ((50+big)* Math.cos(s2) * Math.cos(s2));
			float Y2 = (float) ((50+big)* Math.cos(s2) * Math.sin(s2));
			
			float tempx1 = x1 + (float)(x2-x1)*t/314 ;
			float tempx2 = x1 + (float)(x2-x1)*(t+2)/314 ;
			float tempy1 = y1 + (float)(y2-y1)*t/314 ;
			float tempy2 = y1 + (float)(y2-y1)*(t+2)/314 ;

			g.drawLine((int)(tempx1+X1), (int)(tempy1+Y1), (int)(tempx2+X2), (int)(tempy2+Y2));
		}
	
	}
	
	public void drawParam3Line(int x1, int y1, int x2, int y2) {
		
		for (int t=0; t<32; t=t+1) {	
			float s1 = (float)(t)/10;
			double r1 = (double)(Math.random()*5);
			double r2 = (double)(Math.random()*5);
			float X1 = (float) (r2*10 * Math.sin(r1*s1) * Math.cos(s1));
			float Y1 = (float) (r1*10 * Math.cos(r2*s1) * Math.sin(s1));	
			float tempx = (float)(t*(x1-x2))/32;
			float tempy = (float)(t*(y1-y2))/32;
			g.drawLine((int)tempx+x1, (int)tempy+y1, (int)(tempx+X1)+x1, (int)(tempy+Y1)+y1);
		}
	}
	
		
	
	public void drawParam4Line(int x1, int y1, int x2, int y2) {
	
			g.drawLine(x1,y1,x2,y2);

	}
	

		
	public void drawParam5Line(int x1, int y1, int x2, int y2) {
		int xStep = (int) ( (float)(x2-x1)/(float)16 );
		int yStep = (int) ( (float)(y2-y1)/(float)16 );
		for (int t=0; t<32; t=t+1) {	

			float r1 = (float)(Math.random()*5);
			float r2 = (float)(Math.random()*5);
			float s1 = (float)(t)/10;
			float X1 = (float) (r2*10 * Math.cos(r1*s1) * Math.cos(s1));
			float Y1 = (float) (r1*10 * Math.cos(r2*s1) * Math.sin(s1));
			g.drawLine(x1+(int)X1+t*xStep, y1+(int)Y1+t*yStep, x1+(int)X1+(t+1)*xStep, y1+(int)Y1+(t+1)*yStep);
		}	
	}



	public void drawParam6Line(int x1, int y1, int x2, int y2) {
		for (int t=0; t<32; t=t+1) {	
			float s1 = (float)(t)/10;
			float s2 = (float)(t+1)/10;
			float X1 = (float) (30 * Math.cos(3*s1) * Math.cos(s1));
			float Y1 = (float) (30 * Math.cos(3*s1) * Math.sin(s1));
			float X2 = (float) (30 * Math.cos(3*s2) * Math.cos(s2));
			float Y2 = (float) (30 * Math.cos(3*s2) * Math.sin(s2));	
			float tempx = ((float)x1*(32-(float)t)-(float)x2*(float)t)/32;
			float tempy = ((float)y1*(32-(float)t)-(float)y2*(float)t)/32;
			g.drawLine((int)tempx, (int)tempy, (int)(tempx+X1), (int)(tempy+Y1));
		}
	}


	public void drawParam7Line(int x1, int y1, int x2, int y2) {

		int newX1 = x1; 
		int newY1 = y1;
		int newX2 = x1; 
		int newY2 = y1;

		for (int t=0; t<32; t=t+1) {	

			newX1 = newX1 + t*(x2-x1)/32;
			newY1 = newY1 + t*(y2-y1)/32;
			newX2 = newX2 + (t+1)*(x2-x1)/32;
			newY2 = newY2 + (t+1)*(y2-y1)/32;

			float s = (float)(t)/10;

			float X = (float) ( Math.sin(3*s) * 50 * Math.cos(s));
			float Y = (float) ( Math.cos(3*s) * 50 * Math.sin(s));

			g.drawLine((int)(X+newX1), (int)(Y+newY1), (int)(X+newX2), (int)(Y+newY2));
		}
	}
	
	
	
	public void drawParam8Line(int x1, int y1, int x2, int y2) {

			float slope = 3*(float)(y2-y1)/(float)(x2-x1);
			if (slope>15) slope = 3;
			if (slope==0) slope = 1;
		
		for (int t=0; t<12; t=t+1) {	
			
			float tempx1 = (float)x1+(float)t*(float)(Math.abs(x2-x1)+1)/(float)(9);
			float tempy1 = (float)(slope*(36*Math.sin(tempx1*Math.PI/(float)(Math.abs(x2-x1)+1))) + y1) ;

			float tempx2 = (float)x1+(float)(t+1)*(float)(Math.abs(x2-x1)+3)/(float)(9);
			float tempy2 = (float)(slope*(36*Math.cos(tempx2*Math.PI/(float)(2*Math.abs(x2-x1)+1))) + y1) ;
			
			g.drawLine((int)tempx1, (int)tempy1, (int)tempx2, (int)tempy2);
		}
	}
	
		
	
	public void drawParam9Line(int x1, int y1, int x2, int y2) {

		double love = 1;

		for (int t=0; t<15; t=t+1) {
			int s = t+1;
			float tempx1 = (float)(x1*(14-t)+ x2*t) /(float)14;
			float tempy1 = (float)(y1*(14-t)+ y2*t) /(float)14;
			float tempx2 = (float)(x1*(14-s)+ x2*s) /(float)14;
			float tempy2 = (float)(y1*(14-s)+ y2*s) /(float)14;

			g.drawLine((int)(tempx1-love), (int)(tempy1+love), (int)(tempx2 - (love * 1.5)), (int)(tempy2 + (love * 1.5)));
			love = love * 1.5;
		}

	}


		
	public void drawParam19Line(int x1, int y1, int x2, int y2) {

			float slope = (float)(y2-y1)/(float)(x2-x1);
			if (slope>15) slope = 3;
			if (slope==0) slope = 1;
		
		for (int t=0; t<9; t=t+1) {	
			
			float tempx1 = (float)x1+(float)t*(float)(Math.abs(x2-x1)+1)/(float)(9);
			float tempy1 = (float)(slope*(36*Math.cos(tempx1*Math.PI/(float)(5*Math.abs(x2-x1)+1))) + y1) ;

			float tempx2 = (float)x1+(float)(t+1)*(float)(Math.abs(x2-x1)+3)/(float)(9);
			float tempy2 = (float)(slope*(36*Math.sin(tempx2*Math.PI/(float)(5*Math.abs(x2-x1)+1))) + y1) ;
			
			g.drawLine((int)tempx1, (int)tempy1, (int)tempx2, (int)tempy2);
		}

	}

	public void drawParam10Line(int x1, int y1, int x2, int y2) {
		
		
		for (int t=0; t<8; t=t+1) {	
			float s1 = (float)(t)/10;
			float s2 = (float)(t+1)/10;
			float X1 = (float) (30 * Math.cos(3*s1) * Math.cos(s1));
			float Y1 = (float) (30 * Math.cos(3*s1) * Math.sin(s1));
			float X2 = (float) (30 * Math.cos(3*s2) * Math.cos(s2));
			float Y2 = (float) (30 * Math.cos(3*s2) * Math.sin(s2));	
			float tempx = ((float)x1*(8-(float)t)-(float)x2*(float)t)/8;
			float tempy = ((float)y1*(8-(float)t)-(float)y2*(float)t)/8;
			g.drawLine((int)tempx+100, 100+(int)tempy, (int)(tempx+X1), (int)(tempy-Y1));
		}	
		
	}

		public void drawParam12Line(int x1, int y1, int x2, int y2) {

		float slope = (float)(y2-y1)/(float)(x2-x1);
		
		for (int t=0; t<9; t=t+1) {	
			
			float tempx1 = (float)x1+(float)t*(float)(Math.abs(x2-x1)+3)/(float)(9);
			float tempy1 = (float)(slope*(36*Math.sin(tempx1*Math.PI/(float)(Math.abs(x2-x1)+1)))*(Math.cos(tempx1*Math.PI/(float)(3*Math.abs(x2-x1)+1))) + y1) ;

			float tempx2 = (float)x1+(float)(t+1)*(float)(Math.abs(x2-x1)+3)/(float)(9);
			float tempy2 = (float)(slope*(36*Math.sin(tempx2*Math.PI/(float)(2*Math.abs(x2-x1)+1)))*(Math.cos(tempx2*Math.PI/(float)(Math.abs(x2-x1)+1))) + y1) ;
			
			g.drawLine((int)tempx1, (int)tempy1, (int)tempx2, (int)tempy2);
		}
		
	}



}
