int width  = getSize().width;
    int height = getSize().height;


These statements get the width and height (in pixels) of the rectangle that the Web browser has allocated to the applet.

Center of the Rectangle

The width and height are needed to determine the size of the star that fits in the rectangle.

Next the applet sets the background color to white and the pen color to blue. The lines of the figure will be drawn with the pen.

import java.applet.Applet ;
import java.awt.* ;

public class SnowFlakeBasic extends Applet
  Graphics graph;
  // draw a star consisting of six lines of length size
  // radiating from the point (x,y)
  private void drawStar( int x, int y, int size )
    .  .  .  .
  public void paint ( Graphics gr )
    graph = gr;
    int width  = getSize().width;
    int height = getSize().height;
    int min;
    setBackground( Color.white );   // set the background color
    gr.setColor  (  );   // set the drawing pen color
    // ensure that the star fits in the rectangle of the applet 
    if ( height > width )
      min = height;
      min = width;
    drawStar( , , min/4 );  // draw star in center

To draw a symmetrical star, find the minimum of the drawing area rectangle's width and height. Base the length of the radiating lines on this distance. The length could be min/2 if all we were drawing were the star, but let us make the length min/4 so that there is room for the rest of the snowflake.

Next the star is drawn in the center of the rectangle.


Fill in the blanks so that the center of the star is the center of the rectangle.