コード例 #1
0
 public void paint(Graphics g) {
   Graphics2D g_2d = (Graphics2D) g;
   Ellipse2D ellipse = new Ellipse2D.Double(0, 2, 80, 80);
   Rectangle2D rect = new Rectangle2D.Double(40, 2, 80, 80);
   Area a1 = new Area(ellipse);
   Area a2 = new Area(rect);
   a1.intersect(a2); // "Óë"
   g_2d.fill(a1);
   ellipse.setFrame(130, 2, 80, 80);
   rect.setFrame(170, 2, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.add(a2); // "»ò"
   g_2d.draw(a1);
   ellipse.setFrame(0, 90, 80, 80);
   rect.setFrame(40, 90, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.subtract(a2); // "²î"
   g_2d.draw(a1);
   ellipse.setFrame(130, 90, 80, 80);
   rect.setFrame(170, 90, 80, 80);
   a1 = new Area(ellipse);
   a2 = new Area(rect);
   a1.exclusiveOr(a2); // "Òì»ò"
   g_2d.fill(a1);
 }
コード例 #2
0
ファイル: draw.java プロジェクト: bossiernesto/jvmbytecodes
  private static final Shape createMask(int width, int height) {
    Shape outside = new Rectangle2D.Double(0, 0, width, height);
    Shape inside = new RoundRectangle2D.Double(10, 10, width - 20, height - 20, 50, 50);

    Area area = new Area(outside);
    area.subtract(new Area(inside));

    return area;
  }
コード例 #3
0
ファイル: AreaMaker.java プロジェクト: aang531/RSBot
  @Override
  public void repaint(Graphics g) {
    if (tiles.size() >= 2) {
      g.setColor(new Color(255, 255, 255, 255));
      Tile[] t = new Tile[tiles.size()];
      tiles.toArray(t);
      Area a = new Area(t);
      for (int i = 0; i < a.getPolygon().npoints; i++) {
        Point p =
            new Point(
                tiles.get(i).matrix(ctx).bounds().xpoints[0],
                tiles.get(i).matrix(ctx).bounds().ypoints[0]);
        Point pp;
        if (i == a.getPolygon().npoints - 1)
          pp =
              new Point(
                  tiles.get(0).matrix(ctx).bounds().xpoints[0],
                  tiles.get(0).matrix(ctx).bounds().ypoints[0]);
        else
          pp =
              new Point(
                  tiles.get(i + 1).matrix(ctx).bounds().xpoints[0],
                  tiles.get(i + 1).matrix(ctx).bounds().ypoints[0]);
        g.drawLine(p.x, p.y, pp.x, pp.y);
      }
      g.drawPolygon(a.getPolygon());

      if (a.contains(ctx.players.local())) {
        g.setColor(new Color(0, 255, 0, 100));
      } else {
        g.setColor(new Color(255, 0, 0, 100));
      }
      g.fillPolygon(ctx.players.local().tile().matrix(ctx).bounds());
    } else {
      g.setColor(new Color(255, 0, 0, 100));
      g.fillPolygon(ctx.players.local().tile().matrix(ctx).bounds());
    }
    for (int i = 0; i < tiles.size(); i++) {
      if (i == gui.tileList.getSelectedIndex()) g.setColor(Color.yellow);
      else g.setColor(new Color(0, 0, 255, 150));
      g.fillPolygon(tiles.get(i).matrix(ctx).bounds());
    }
  }