/**
 *  RandomPixels draws a series of random points on the screen.  This is a 
 *  good example of how to use Java's Random class to construct random numbers.
 *  Also shows the useage of setPixelColor().
 */

import java.awt.*;
import javax.swing.*;
import com.otherwise.jurtle.Turtle;
import java.util.Random;

public class RandomPixels extends Turtle
{


    /**
     *  Main entry point.
     */
    public void runTurtle()
    {
        setAutoUpdate( false );
        hideTurtle();
        Random rnd = new Random();
        Dimension size = getDisplaySize();

        int count = 0;
        while ( count < 20000 )
        {
            if ( count % 50 == 0 )
                updateDisplay();
            int x = rnd.nextInt( size.width );
            int y = rnd.nextInt( size.height );
            setPixelColor( x, y, new Color( rnd.nextInt( 255 ),
                                            rnd.nextInt( 255 ),
                                            rnd.nextInt( 255 ) ) );
            count++;
        }
    }


}
