/*
  Author: Philip Chan

  Description: Drawing basic shapes such as lines and circles.  Using
  the concepts for lines and circles, we can draw a ball and move it
  in a straight line or circle.  Methods/actions to be completed:

  drawLine
  drawCircle
  drawFilledCircle -- can be used to represent a ball
  moveBall
  moveBallInCircle
 */

import java.awt.*;

public class Ball
{
    final static Color BLACK = Color.BLACK;
    final static Color BLUE = Color.BLUE;
    final static Color CYAN = Color.CYAN;
    final static Color GRAY = Color.GRAY;
    final static Color GREEN = Color.GREEN;
    final static Color MAGENTA = Color.MAGENTA;
    final static Color ORANGE = Color.ORANGE;
    final static Color PINK = Color.PINK;
    final static Color RED = Color.RED;
    final static Color WHITE = Color.WHITE;
    final static Color YELLOW = Color.YELLOW;


    // Part 1:
    // draw a line between (x1,y1) and (x2,y2) with color 
    public static void drawLine(Picture pic, int x1, int y1, int x2, int y2, Color color)
    {
	// pic.set(x,y,color) sets color at coordinates x,y
	// "casting" allows you to convert int to double and vice versa:
	// (int)doubleValue, (double)intValue

	// start your instructions here







	pic.show();
    }

    // Part 2:
    // draw a circle with the center at (a,b) and radius r
    public static void drawCircle(Picture pic, int a, int b, int r, Color color)
    {
	// start your instructions here







	pic.show();
    }

    // Part 3:
    // draw a filled circle with the center at (a,b) and radius r
    public static void drawFilledCircle(Picture pic, int a, int b, int r, Color color)
    {
	// start your instructions here








	pic.show();
    }


    // Part 4:
    // move ball of radius from (x1,y1) to (x2,y2) 
    //   with delay (milliseconds) between the two frames
    public static void moveBall(Picture pic, int radius, int x1, int y1, 
				int x2, int y2, Color color, int delay) 
	throws InterruptedException
    {
	// Thread.sleep(delay) -- wait for delay milliseconds
	// setColor(pic, WHITE) -- clear the picture
	// pic.show() -- display the picture

	// start your instructions here















	pic.show();
    }


    // Part 5:
    // move ball with radius ballRadius from (x1,y1) back to (x1,y1)
    //    in a circle centered at (a,b) with radius r
    // with delay (milliseconds) between frames
    public static void moveBallInCircle(Picture pic, int ballradius, int x1, int y1, 
					int a, int b, int r, Color color, int delay) 
	throws InterruptedException
    {
	// start your instructions here
	// setColor(pic, WHITE);  // **** uncomment this line















	pic.show();
    }



    public static void main (String[] args) throws InterruptedException
    {
	Picture pic = new Picture(300,200);
	pic.setOriginLowerLeft();  // so we can use the regular x,y coordinates

	setColor(pic, WHITE);
	pic.show();

	// torso
	drawLine(pic, 30, 40, 30, 80, BLACK);
	Thread.sleep(1000);
	// left leg
	drawLine(pic, 10, 0, 30, 40, BLACK);
	Thread.sleep(1000);
	// right leg
	//drawLine(pic, 50, 0, 30, 40, BLACK);
	drawLine(pic, 30, 40, 50, 0, BLACK); // x1 < x2
	Thread.sleep(1000);
	// left arm
	drawLine(pic, 10, 40, 30, 80, BLACK);
	Thread.sleep(1000);
	// right arm
	//drawLine(pic, 50, 40, 30, 80, BLACK);
	drawLine(pic, 30, 80, 50, 40, BLACK); // x1 < x2
	Thread.sleep(1000);

	// head
	drawCircle(pic, 30, 95, 15, BLACK);
	Thread.sleep(1000);

	// sun
	drawFilledCircle(pic, 250, 170, 20, ORANGE);
	Thread.sleep(1000);

	// ball
	drawFilledCircle(pic, 60, 10, 10, BLUE);
	Thread.sleep(1000);

	// to the right wall
	moveBall(pic, 10, 60, 10, 288, 50, BLUE, 1);
	// back to the head
	moveBall(pic, 10, 288, 50, 55, 100, BLUE, 1);
	// to the sun
	moveBall(pic, 10, 55, 100, 220, 170, BLUE, 1);
	// back to the head
	moveBall(pic, 10, 220, 170, 50, 100, BLUE, 1);

	Thread.sleep(1000);

	// move ball with radius 10 
        // in a circle from (30,100) to (20,180) with .01 sec delay 
        //    centered at (100,100) and with a radius of 70 
        //    10 millisec delay between frames
	moveBallInCircle(pic, 10, 30, 100, 100, 100, 70, GREEN, 10);
    }

    // set the color of picture pic to color
    public static void setColor(Picture pic, Color color)
    {
	for (int x = 0; x < pic.width(); x++)
	    for (int y = 0; y < pic.height(); y++)
		pic.set(x, y, color);
    }
}
