/*********************************************************************************************/
/*                                                                                           */
/*  Java 3D Engine Basics Tutorials - Tut x.x                                                */
/*  Auth: bkenwright@xbdev.net                                                               */
/*                                                                                           */
/*  Setting pixels with java 1.1 and later!                                                  */
/*                                                                                           */
/*********************************************************************************************/

import java.awt.image.*;
import java.awt.*;
import java.applet.*;

public class setpixel extends Applet 
{
  Image myImage;


  public void init() 
  {
  	 Dimension appletSize = this.getSize();
	 myImage = createImage(appletSize.width,appletSize.height);
   	 Graphics g = myImage.getGraphics();

  }// End of init(..)

  public void paint(Graphics g) 
  {      g.drawImage(myImage,0,0,this);
  }// End of paint(..)

  public void setPixel(Image image, int x, int y, Color color ) 
  {
     Graphics g = image.getGraphics( );
     g.setColor( color );
     g.fillRect( x, y, 1, 1 );
     // or use g.drawLine(0,0,x,y);
     g.dispose( );
  }// End of setPixel(..)

  public void update(Graphics g){ paint(g); }       // Is called when we call repaint()


/*********************************************************************************************/
/*                                                                                           */
/*  Capture mouse movement                                                                   */
/*    Parameters:                                                                            */
/*    evt is The event...                                                                    */
/*    x is the x mouse position                                                              */
/*    y is the y mouse position                                                              */
/*    return whether or not we handled the event                                             */
/*                                                                                           */
/*********************************************************************************************/


        public boolean mouseMove(Event evt, int x, int y)
        {        setPixel(myImage, x, y, Color.red );
                 repaint();
  	         return true;
        }// End of mouseDrag(..)




// THESE ARE NOT USED...BUT I THOUGHT YOU MIGHT LIKE TO TAKE A LOOKSY AT THEM


/*********************************************************************************************/
/*                                                                                           */
/*  Capture event when mouse is pressed                                                      */
/*    Parameters:                                                                            */
/*    evt is The event...                                                                    */
/*    x is the x mouse position                                                              */
/*    y is the y mouse position                                                              */
/*    return whether or not we handled the event                                             */
/*                                                                                           */
/*********************************************************************************************/

	public boolean mouseDown(Event evt, int x, int y)
        {        System.out.println( "MouseDown" );
		 return false;
	}// End of mouseDown(..)

/*********************************************************************************************/
/*                                                                                           */
/*  Capture mouse release                                                                    */
/*    Parameters:                                                                            */
/*    evt is The event...                                                                    */
/*    x is the x mouse position                                                              */
/*    y is the y mouse position                                                              */
/*    return whether or not we handled the event                                             */
/*                                                                                           */
/*********************************************************************************************/

	public boolean mouseUp(Event evt, int x, int y)
	{

		return false;
	}// End of mouseUp(..)
	
/*********************************************************************************************/
/*                                                                                           */
/*  Capture mouse drags                                                                      */
/*    Parameters:                                                                            */
/*    evt is The event...                                                                    */
/*    x is the x mouse position                                                              */
/*    y is the y mouse position                                                              */
/*    return whether or not we handled the event                                             */
/*                                                                                           */
/*********************************************************************************************/

	public boolean mouseDrag(Event evt, int x, int y)
	{
  	        return true;
	}// End of mouseDrag(..)




}// End of our Applet

