

import java.util.*;
import java.awt.*;
import java.applet.*;


public class LinesTest03 extends Applet {
	
	int w, h;
	int posx, posy;

	Color c = new Color(0,0,0);

	private Image offImage;
   	private Dimension offDimension;
	private Graphics offGraphics;


	public void init() {
		
		Dimension d = this.size(); 

		w = d.width;
		h = d.height;
		
		if ((offImage == null) || (w != offDimension.width) || (h != offDimension.height)) {
			offImage = createImage(w, h);
			offDimension = d;
			offGraphics = offImage.getGraphics();
		}

		repaint();
	}
	
	
	public void update(Graphics g) {
		paint(g);
	}
	
	public void paint(Graphics g) {


		g.drawImage(offImage, 0, 0, this);
	}
		

	public boolean mouseDown(Event e, int x, int y) {	
		posx=x;
		posy=y;

		return true;
	}
	
	
	public boolean mouseDrag(Event e, int x, int y) {			
		drawParam2Line(x,y,posx,posy);
		posx=x;
		posy=y;
		repaint();
		return true;
	}
	
	public void drawParam2Line(int x1, int y1, int x2, int y2) {

						offGraphics.setColor(Color.black);
		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 ;

			offGraphics.drawLine((int)(tempx1+X1), (int)(tempy1+Y1), (int)(tempx2+X2), (int)(tempy2+Y2));
		}
	
	}
		
}


				










