/* Listing2501.java */

import java.awt.*;
import java.awt.event.*;

public class Listing2501
extends Frame
{
  public static void main(String[] args)
  {
    Listing2501 wnd = new Listing2501();
  }

  public Listing2501()
  {
    super("Der Farbenkreis");
    addWindowListener(new WindowClosingAdapter(true));
    setSize(300,200);
    setVisible(true);
  }

  public void paint(Graphics g)
  {
    int top  = getInsets().top;
    int left = getInsets().left;
    int maxX = getSize().width-left-getInsets().right;
    int maxY = getSize().height-top-getInsets().bottom;
    Color col;
    int[] arx   = {130,160,190};
    int[] ary   = {60,110,60};
    int[] arr   = {50,50,50};
    int[] arcol = {0,0,0};
    boolean paintit;
    int dx, dy;

    for (int y = 0; y < maxY; ++y) {
      for (int x = 0; x < maxX; ++x) {
        paintit = false;
        for (int i = 0; i < arcol.length; ++i) {
          dx = x - arx[i];
          dy = y - ary[i];
          arcol[i] = 0;
          if ((dx*dx+dy*dy) <= arr[i]*arr[i]) {
            arcol[i] = 255;
            paintit = true;
          }
        }
        if (paintit) {
          col = new Color(arcol[0],arcol[1],arcol[2]);
          g.setColor(col);
          g.drawLine(x+left,y+top,x+left+1,y+top+1);
        }
      }
    }
  }
}