package edu.columbia.cs.education.kaleidoscope;

import java.awt.*;


class Swipe extends Thread {

  public void run() {
    while (true) {
      try {
	Thread.sleep(100);
      }
      catch (InterruptedException e) {
      }
    }
  }


  public void Swipe(Graphics g, int width, int height) {

    int i, j;

    Color color = new Color(0, 0, 0);
    g.setColor(color);

    int ran = (int)(Math.random() * 2000);

    if (ran < 1000) {
      for (i = 0; i <= width; i++) {
        g.drawLine(i, 0, width - i + 1, height); 
        try { Thread.sleep(2); }
        catch (InterruptedException e) { }
      }
      for (i = 0; i <= height; i++) {
        g.drawLine(0, height - i, width, 0 + i);
        try { Thread.sleep(2); }
        catch (InterruptedException e) { }
      }
    }
    if (ran >= 1000) {
      for (i = 0; i <= height; i += 2) {
        g.drawLine(0, i, width, i);
        try { Thread.sleep(5); }
        catch (InterruptedException e) { }
      }
      for (i = height; i > 0; i -= 2) {
        g.drawLine(0, i, width, i);
        g.drawLine(0, i + 1, width, i + 1);
        try { Thread.sleep(5); }
        catch (InterruptedException e) { }
      }
    }

  }

}
