
// KeyBoardInput.java
// Robert Sedgewick and Kevin Wayne
// https://stackoverflow.com/questions/37648830/making-a-sine-graph-move
// Slightly reformatted by Andrew Davison, Nov. 2022

/* A circle keeps growing until 'q' is typed.

   Usage:
     > compile KeyBoardInput.java
     > run KeyBoardInput
*/


import java.awt.Color;



public class KeyBoardInput
{
  private static double RADIUS_INCR = 1.0/500.0;

  public static void main(String[] args)
  {
    char ch = 0;  // dummy initial value
    double radius = RADIUS_INCR;

    StdDraw.setCanvasSize(600, 600);
    StdDraw.enableDoubleBuffering();

    while (ch != 'q') {
      if (StdDraw.hasNextKeyTyped())
        ch = StdDraw.nextKeyTyped();

      StdDraw.circle(0.5, 0.5, radius);
      radius += RADIUS_INCR;

      StdDraw.show();
      StdDraw.pause(50);
    }
  } /* main */

}  // end of KeyBoardInput
