Esempio n. 1
0
 public void draw(GOut g) {
   long now = System.currentTimeMillis();
   for (int y = 0; y < gsz.y; y++) {
     for (int x = 0; x < gsz.x; x++) {
       Coord p = bgsz.mul(new Coord(x, y));
       g.image(bg, p);
       Pagina btn = layout[x][y];
       if (btn != null) {
         Tex btex = btn.img.tex();
         g.image(btex, p.add(1, 1));
         if (btn.meter > 0) {
           double m = btn.meter / 1000.0;
           if (btn.dtime > 0) m += (1 - m) * (double) (now - btn.gettime) / (double) btn.dtime;
           m = Utils.clip(m, 0, 1);
           g.chcolor(255, 255, 255, 128);
           g.fellipse(p.add(bgsz.div(2)), bgsz.div(2), 90, (int) (90 + (360 * m)));
           g.chcolor();
         }
         if (btn.newp != 0) {
           if (btn.fstart == 0) {
             btn.fstart = now;
           } else {
             double ph = ((now - btn.fstart) / 1000.0) - (((x + (y * gsz.x)) * 0.15) % 1.0);
             if (ph < 1.25) {
               g.chcolor(255, 255, 255, (int) (255 * ((Math.cos(ph * Math.PI * 2) * -0.5) + 0.5)));
               g.image(glowmask(btn), p.sub(4, 4));
               g.chcolor();
             } else {
               g.chcolor(255, 255, 255, 128);
               g.image(glowmask(btn), p.sub(4, 4));
               g.chcolor();
             }
           }
         }
         if (btn == pressed) {
           g.chcolor(new Color(0, 0, 0, 128));
           g.frect(p.add(1, 1), btex.sz());
           g.chcolor();
         }
       }
     }
   }
   super.draw(g);
   if (dragging != null) {
     final Tex dt = dragging.img.tex();
     ui.drawafter(
         new UI.AfterDraw() {
           public void draw(GOut g) {
             g.image(dt, ui.mc.add(dt.sz().div(2).inv()));
           }
         });
   }
 }
Esempio n. 2
0
 public void draw(GOut g) {
   long now = System.currentTimeMillis();
   int t = (int) (now % 1000);
   int b = (int) (255 * ((t < 500) ? (t) : (1000 - t)) / 500.0f);
   Inventory.invsq(g, Coord.z, gsz);
   for (int y = 0; y < gsz.y; y++) {
     for (int x = 0; x < gsz.x; x++) {
       Coord p = Inventory.sqoff(new Coord(x, y));
       Pagina btn = layout[x][y];
       if (btn != null) {
         Tex btex = btn.img.tex();
         if (btn.newp) {
           g.chcolor(b, 255, b, 255);
         }
         g.image(btex, p);
         g.chcolor();
         if (btn.meter > 0) {
           double m = btn.meter / 1000.0;
           if (btn.dtime > 0) m += (1 - m) * (double) (now - btn.gettime) / (double) btn.dtime;
           m = Utils.clip(m, 0, 1);
           g.chcolor(255, 255, 255, 128);
           g.fellipse(
               p.add(Inventory.isqsz.div(2)), Inventory.isqsz.div(2), 90, (int) (90 + (360 * m)));
           g.chcolor();
         }
         if (btn == pressed) {
           g.chcolor(new Color(0, 0, 0, 128));
           g.frect(p, btex.sz());
           g.chcolor();
         }
       }
     }
   }
   super.draw(g);
   if (dragging != null) {
     final Tex dt = dragging.img.tex();
     ui.drawafter(
         new UI.AfterDraw() {
           public void draw(GOut g) {
             g.image(dt, ui.mc.add(dt.sz().div(2).inv()));
           }
         });
   }
 }
Esempio n. 3
0
 public void tick(float dt) {
   rsmod = Utils.clip(rsmod + (srnd.nextFloat() * 0.005f) - 0.0025f, 0.90f, 1.10f);
   dt *= rsmod;
   boolean build = false;
   if (limit >= 0) {
     if ((limit -= dt) < 0) ldone = true;
   }
   boolean done = ldone;
   for (PoseMod m : mods) {
     m.tick(dt);
     if (!m.done()) done = false;
   }
   if (!stat) build = true;
   if (ipold > 0.0f) {
     if ((ipold -= (dt / ipol)) < 0.0f) {
       ipold = 0.0f;
       old = null;
     }
     build = true;
   }
   if (build) rebuild();
   if (done) done();
 }
Esempio n. 4
0
  public static BufferedImage convolvedown(BufferedImage img, Coord tsz, Convolution filter) {
    Raster in = img.getRaster();
    int w = in.getWidth(), h = in.getHeight(), nb = in.getNumBands();
    double xf = (double) w / (double) tsz.x, ixf = 1.0 / xf;
    double yf = (double) h / (double) tsz.y, iyf = 1.0 / yf;
    double[] ca = new double[nb];
    WritableRaster buf = byteraster(new Coord(tsz.x, h), nb);
    double support = filter.support();

    {
      double[] cf = new double[tsz.x * (int) Math.ceil(2 * support * xf + 2)];
      int[] cl = new int[tsz.x];
      int[] cr = new int[tsz.x];
      for (int x = 0, ci = 0; x < tsz.x; x++) {
        int si = ci;
        double wa = 0.0;
        cl[x] = Math.max((int) Math.floor((x + 0.5 - support) * xf), 0);
        cr[x] = Math.min((int) Math.ceil((x + 0.5 + support) * xf), w - 1);
        for (int sx = cl[x]; sx <= cr[x]; sx++) {
          double tx = ((sx + 0.5) * ixf) - x - 0.5;
          double fw = filter.cval(tx);
          wa += fw;
          cf[ci++] = fw;
        }
        wa = 1.0 / wa;
        for (; si < ci; si++) cf[si] *= wa;
      }
      for (int y = 0; y < h; y++) {
        for (int x = 0, ci = 0; x < tsz.x; x++) {
          for (int b = 0; b < nb; b++) ca[b] = 0.0;
          for (int sx = cl[x]; sx <= cr[x]; sx++) {
            double fw = cf[ci++];
            for (int b = 0; b < nb; b++) ca[b] += in.getSample(sx, y, b) * fw;
          }
          for (int b = 0; b < nb; b++) buf.setSample(x, y, b, Utils.clip((int) ca[b], 0, 255));
        }
      }
    }

    WritableRaster res = byteraster(tsz, nb);
    {
      double[] cf = new double[tsz.y * (int) Math.ceil(2 * support * yf + 2)];
      int[] cu = new int[tsz.y];
      int[] cd = new int[tsz.y];
      for (int y = 0, ci = 0; y < tsz.y; y++) {
        int si = ci;
        double wa = 0.0;
        cu[y] = Math.max((int) Math.floor((y + 0.5 - support) * yf), 0);
        cd[y] = Math.min((int) Math.ceil((y + 0.5 + support) * yf), h - 1);
        for (int sy = cu[y]; sy <= cd[y]; sy++) {
          double ty = ((sy + 0.5) * iyf) - y - 0.5;
          double fw = filter.cval(ty);
          wa += fw;
          cf[ci++] = fw;
        }
        wa = 1.0 / wa;
        for (; si < ci; si++) cf[si] *= wa;
      }
      for (int x = 0; x < tsz.x; x++) {
        for (int y = 0, ci = 0; y < tsz.y; y++) {
          for (int b = 0; b < nb; b++) ca[b] = 0.0;
          for (int sy = cu[y]; sy <= cd[y]; sy++) {
            double fw = cf[ci++];
            for (int b = 0; b < nb; b++) ca[b] += buf.getSample(x, sy, b) * fw;
          }
          for (int b = 0; b < nb; b++) res.setSample(x, y, b, Utils.clip((int) ca[b], 0, 255));
        }
      }
    }
    return (new BufferedImage(img.getColorModel(), res, false, null));
  }