/* Schranke.java */

import java.awt.*;
import java.applet.*;

public class Schranke
extends Applet
{
  private int[] dx;
  private Color[] color;

  public void init()
  {
    String tmp;

    dx = new int[2];
    try {
      dx[0] = Integer.parseInt(
        getParameter("redwidth")
      );
      dx[1] = Integer.parseInt(
        getParameter("whitewidth")
      );
    } catch (NumberFormatException e) {
      dx[0] = 10;
      dx[1] = 10;
    }
    color = new Color[2];
    color[0] = Color.red;
    color[1] = Color.white;
  }

  public void paint(Graphics g)
  {
    int maxX = getSize().width;
    int maxY = getSize().height;
    int x = 0;
    int flg = 0;
    Polygon p;
    while (x <= maxX+maxY/2) {
      p = new Polygon();
      p.addPoint(x,0);
      p.addPoint(x+dx[flg],0);
      p.addPoint(x+dx[flg]-maxY/2,maxY);
      p.addPoint(x-maxY/2,maxY);
      p.addPoint(x,0);
      g.setColor(color[flg]);
      g.fillPolygon(p);
      x += dx[flg];
      flg = (flg==0) ? 1 : 0;
    }
  }
}