Пример #1
0
    public BufferedImage getGridImage() {
      if (rendered) return gridImage;

      if (!loaded) throw new Loading();

      gridImage = TexI.mkbuf(cmaps);

      BufferedImage[] texes = new BufferedImage[256];

      Coord c = new Coord();
      for (c.y = 0; c.y < cmaps.y; c.y++) {
        for (c.x = 0; c.x < cmaps.x; c.x++) {
          int t = gettile(c);
          BufferedImage tex = tileimg(t, texes);
          if (tex != null)
            gridImage.setRGB(
                c.x,
                c.y,
                tex.getRGB(
                    Utils.floormod(c.x, tex.getWidth()), Utils.floormod(c.y, tex.getHeight())));
        }
      }
      for (c.y = 1; c.y < cmaps.y - 1; c.y++) {
        for (c.x = 1; c.x < cmaps.x - 1; c.x++) {
          int t = gettile(c);
          if ((gettile(c.add(-1, 0)) > t)
              || (gettile(c.add(1, 0)) > t)
              || (gettile(c.add(0, -1)) > t)
              || (gettile(c.add(0, 1)) > t)) gridImage.setRGB(c.x, c.y, Color.BLACK.getRGB());
        }
      }
      rendered = true;
      return gridImage;
    }
Пример #2
0
 public float getcz(float px, float py) {
   float tw = tilesz.x, th = tilesz.y;
   Coord ul = new Coord(Utils.floordiv(px, tw), Utils.floordiv(py, th));
   float sx = Utils.floormod(px, tw) / tw;
   float sy = Utils.floormod(py, th) / th;
   return (((1.0f - sy) * (((1.0f - sx) * getz(ul)) + (sx * getz(ul.add(1, 0)))))
       + (sy * (((1.0f - sx) * getz(ul.add(0, 1))) + (sx * getz(ul.add(1, 1))))));
 }
Пример #3
0
 public BufferedImage drawmap(Coord ul, Coord sz) {
   BufferedImage[] texes = new BufferedImage[256];
   MCache m = ui.sess.glob.map;
   BufferedImage buf = TexI.mkbuf(sz);
   Coord c = new Coord();
   for (c.y = 0; c.y < sz.y; c.y++) {
     for (c.x = 0; c.x < sz.x; c.x++) {
       int t = m.gettile(ul.add(c));
       BufferedImage tex = tileimg(t, texes);
       int rgb = 0;
       if (tex != null)
         rgb =
             tex.getRGB(
                 Utils.floormod(c.x + ul.x, tex.getWidth()),
                 Utils.floormod(c.y + ul.y, tex.getHeight()));
       buf.setRGB(c.x, c.y, rgb);
     }
   }
   for (c.y = 1; c.y < sz.y - 1; c.y++) {
     for (c.x = 1; c.x < sz.x - 1; c.x++) {
       int t = m.gettile(ul.add(c));
       Tiler tl = m.tiler(t);
       if (tl instanceof Ridges.RidgeTile) {
         if (Ridges.brokenp(m, ul.add(c))) {
           for (int y = c.y - 1; y <= c.y + 1; y++) {
             for (int x = c.x - 1; x <= c.x + 1; x++) {
               Color cc = new Color(buf.getRGB(x, y));
               buf.setRGB(
                   x,
                   y,
                   Utils.blendcol(cc, Color.BLACK, ((x == c.x) && (y == c.y)) ? 1 : 0.1).getRGB());
             }
           }
         }
       }
     }
   }
   for (c.y = 0; c.y < sz.y; c.y++) {
     for (c.x = 0; c.x < sz.x; c.x++) {
       int t = m.gettile(ul.add(c));
       if ((m.gettile(ul.add(c).add(-1, 0)) > t)
           || (m.gettile(ul.add(c).add(1, 0)) > t)
           || (m.gettile(ul.add(c).add(0, -1)) > t)
           || (m.gettile(ul.add(c).add(0, 1)) > t)) buf.setRGB(c.x, c.y, Color.BLACK.getRGB());
     }
   }
   return (buf);
 }
Пример #4
0
 public static WritableRaster tilemod(WritableRaster dst, Raster tile, Coord off) {
   int w = dst.getWidth(), h = dst.getHeight(), b = dst.getNumBands();
   int tw = tile.getWidth(), th = tile.getHeight(), tb = tile.getNumBands();
   for (int y = 0; y < h; y++) {
     for (int x = 0; x < w; x++) {
       int tx = Utils.floormod(x - off.x, tw), ty = Utils.floormod(y - off.y, th);
       for (int i = 0; i < b; i++)
         dst.setSample(
             x,
             y,
             i,
             (dst.getSample(x, y, i) * ((i < tb) ? tile.getSample(tx, ty, i) : 255)) / 255);
     }
   }
   return (dst);
 }