示例#1
0
 protected void fill(GOut g) {
   BGL gl = g.gl;
   Coord dim = new Coord(tdim, tdim);
   for (int i = 0; i < order.length; i++) {
     ByteBuffer data =
         ByteBuffer.wrap(
             TexI.convert(back, dim, new Coord(order[i][0] * tdim, order[i][1] * tdim), dim));
     gl.glTexImage2D(
         GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
         0,
         GL.GL_RGBA,
         tdim,
         tdim,
         0,
         GL.GL_RGBA,
         GL.GL_UNSIGNED_BYTE,
         data);
   }
 }
示例#2
0
 public static BufferedImage monochromize(BufferedImage img, Color col) {
   Coord sz = Utils.imgsz(img);
   BufferedImage ret = TexI.mkbuf(sz);
   Raster src = img.getRaster();
   WritableRaster dst = ret.getRaster();
   boolean hasalpha = (src.getNumBands() == 4);
   for (int y = 0; y < sz.y; y++) {
     for (int x = 0; x < sz.x; x++) {
       int r = src.getSample(x, y, 0), g = src.getSample(x, y, 1), b = src.getSample(x, y, 2);
       int a = hasalpha ? src.getSample(x, y, 3) : 255;
       int max = Math.max(r, Math.max(g, b)), min = Math.min(r, Math.min(g, b));
       int val = (max + min) / 2;
       dst.setSample(x, y, 0, (col.getRed() * val) / 255);
       dst.setSample(x, y, 1, (col.getGreen() * val) / 255);
       dst.setSample(x, y, 2, (col.getBlue() * val) / 255);
       dst.setSample(x, y, 3, (col.getAlpha() * a) / 255);
     }
   }
   return (ret);
 }
示例#3
0
 public void tick(double dt) {
   if (updt) {
     nw = 0;
     int aw = 0;
     for (TypeMod m : mods) {
       if (m.rn == null) {
         try {
           BufferedImage img = m.t.get().layer(Resource.imgc).img;
           String nm = m.t.get().layer(Resource.tooltip).t;
           Text rt = tnf.render(nm);
           int h = Inventory.sqsz.y;
           BufferedImage buf = TexI.mkbuf(new Coord(img.getWidth() + 10 + rt.sz().x, h));
           Graphics g = buf.getGraphics();
           g.drawImage(img, 0, (h - img.getHeight()) / 2, null);
           g.drawImage(rt.img, img.getWidth() + 10, (h - rt.sz().y) / 2, null);
           g.dispose();
           m.rn = new TexI(rasterimg(blurmask2(buf.getRaster(), 2, 1, new Color(32, 0, 0))));
           m.rh = new TexI(rasterimg(blurmask2(buf.getRaster(), 2, 1, new Color(192, 128, 0))));
         } catch (Loading l) {
         }
       }
       if (m.ra == null) {
         Text rt =
             tnf.render(
                 (int) Math.round(m.a * 100) + "%",
                 new Color(255, (int) (255 * m.a), (int) (255 * m.a)));
         m.ra = new TexI(rasterimg(blurmask2(rt.img.getRaster(), 2, 1, new Color(0, 0, 0))));
       }
       nw = Math.max(nw, m.rn.sz().x);
       aw = Math.max(aw, m.ra.sz().x);
     }
     int h = (Inventory.sqsz.y + 5) * mods.size();
     h += levels.sz().y + 20;
     resize(new Coord(Math.max(nw + 20 + aw, boxsz.x), h));
     this.c = Gobble.this.parentpos(parent).add(boxc).add(0, boxsz.y + 5);
     updt = false;
   }
 }