コード例 #1
0
  @Override
  public synchronized void line(V2 start, V2 end) {
    // move based on camera position where applicable
    V2 pov_start = (use_camera) ? camera.getPerspective(start) : start;
    V2 pov_end = (use_camera) ? camera.getPerspective(end) : end;

    draw_queue.add(
        new DrawShape(new Line2D.Float(pov_start.x, pov_start.y, pov_end.x, pov_end.y), false));
    // lines are not filled
  }
コード例 #2
0
  @Override
  public void triangle(V2 a, V2 b, V2 c, boolean fill) {
    V2 pa = (use_camera) ? camera.getPerspective(a) : a,
        pb = (use_camera) ? camera.getPerspective(b) : b,
        pc = (use_camera) ? camera.getPerspective(c) : c;

    int xpts[] = {(int) pa.x, (int) pb.x, (int) pc.x},
        ypts[] = {(int) pa.y, (int) pb.y, (int) pc.y};
    draw_queue.add(new DrawShape(new Polygon(xpts, ypts, 3), fill));
  }
コード例 #3
0
  @Override
  public synchronized void box(Rect rect, boolean fill) {
    // move based on camera position where applicable
    Rect pov_rect = (use_camera) ? camera.getPerspective(rect).ceil() : rect;

    draw_queue.add(
        new DrawShape(
            new Rectangle2D.Float(
                pov_rect.x, pov_rect.y,
                pov_rect.w, pov_rect.h),
            fill));
  }
コード例 #4
0
  @Override
  public synchronized void circle(V2 centre, float radius, boolean fill) {
    // move based on camera position where applicable
    V2 pov_centre;
    if (use_camera) {
      radius *= camera.getZoom();
      pov_centre = camera.getPerspective(centre);
    } else pov_centre = centre;

    draw_queue.add(
        new DrawShape(
            new Ellipse2D.Float(
                pov_centre.x - radius, pov_centre.y - radius, radius * 2, radius * 2),
            fill));
  }
コード例 #5
0
  @Override
  public void angleBox(V2 o, V2 d, float size, boolean fill) {
    // move based on camera position where applicable
    V2 po = (use_camera) ? camera.getPerspective(o) : o;
    // scale direction-vector based on zoom
    V2 pd = (use_camera) ? d.clone().scale(camera.getZoom() * size) : d.clone().scale(size);

    int
        xpts
        [] =
            {
              (int) (po.x + pd.x + pd.y), (int) (po.x + pd.x - pd.y),
              (int) (po.x + -pd.x - pd.y), (int) (po.x + -pd.x + pd.y)
            },
        ypts
        [] =
            {
              (int) (po.y + -pd.x + pd.y), (int) (po.y + pd.x + pd.y),
              (int) (po.y + pd.x - pd.y), (int) (po.y + -pd.x - pd.y)
            };
    draw_queue.add(new DrawShape(new Polygon(xpts, ypts, 4), fill));
  }
コード例 #6
0
 @Override
 public synchronized void text(String string, V2 position) {
   // move based on camera position where applicable
   V2 pov_pos = (use_camera) ? camera.getPerspective(position) : position;
   draw_queue.add(new DrawText(string, pov_pos));
 }
コード例 #7
0
 // methods
 public DrawImage(Rect source, Rect dest, BufferedImage image, ICamera c) {
   this.source = source;
   this.dest = (c != null) ? c.getPerspective(dest).ceil() : dest;
   this.image = image;
 }