コード例 #1
0
ファイル: LGradation.java プロジェクト: 207h2Flogintvg/LGame
 public synchronized void drawWidth(LGraphics g, int x, int y) {
   try {
     if (drawWidth == null) {
       drawWidth = new LImage(width, height, true);
       LGraphics gl = drawWidth.getLGraphics();
       for (int i = 0; i < width; i++) {
         gl.setColor(
             new Color(
                 (start.getRed() * (width - i)) / width + (end.getRed() * i) / width,
                 (start.getGreen() * (width - i)) / width + (end.getGreen() * i) / width,
                 (start.getBlue() * (width - i)) / width + (end.getBlue() * i) / width,
                 alpha));
         gl.drawLine(i, 0, i, height);
       }
       gl.dispose();
       gl = null;
     }
     g.drawImage(drawWidth, x, y);
   } catch (Exception e) {
     for (int i = 0; i < width; i++) {
       g.setColor(
           new Color(
               (start.getRed() * (width - i)) / width + (end.getRed() * i) / width,
               (start.getGreen() * (width - i)) / width + (end.getGreen() * i) / width,
               (start.getBlue() * (width - i)) / width + (end.getBlue() * i) / width,
               alpha));
       g.drawLine(i + x, y, i + x, y + height);
     }
   }
 }
コード例 #2
0
ファイル: LGradation.java プロジェクト: 207h2Flogintvg/LGame
 public synchronized void drawHeight(LGraphics g, int x, int y) {
   try {
     if (drawHeight == null) {
       drawHeight = new LImage(width, height, true);
       LGraphics gl = drawHeight.getLGraphics();
       for (int i = 0; i < height; i++) {
         gl.setColor(
             new Color(
                 (start.getRed() * (height - i)) / height + (end.getRed() * i) / height,
                 (start.getGreen() * (height - i)) / height + (end.getGreen() * i) / height,
                 (start.getBlue() * (height - i)) / height + (end.getBlue() * i) / height,
                 alpha));
         gl.drawLine(0, i, width, i);
       }
       gl.dispose();
       gl = null;
     }
     g.drawImage(drawHeight, x, y);
   } catch (Exception e) {
     for (int i = 0; i < height; i++) {
       g.setColor(
           new Color(
               (start.getRed() * (height - i)) / height + (end.getRed() * i) / height,
               (start.getGreen() * (height - i)) / height + (end.getGreen() * i) / height,
               (start.getBlue() * (height - i)) / height + (end.getBlue() * i) / height,
               alpha));
       g.drawLine(x, i + y, x + width, i + y);
     }
   }
 }
コード例 #3
0
  /**
   * 绘制选单
   *
   * @param g
   * @param color1
   * @param color2
   */
  public void drawChoice(LGraphics g) {
    if (!visible) {
      return;
    }
    int x1 = this.getX() - 5;
    int y1 = this.getY();
    int x2 = this.getWidth() + 20;
    int y2 = this.getAllHeight() + 10;
    int w = x2 + 15;
    int h = y2 + 10;
    if (dialogImage == null) {
      dialogImage = createDefaultDialog(w, h);
    }

    Font font = g.getFont();
    try {
      g.setFont(defFont);
      // 选中项
      int i = getDrawContent();

      g.drawImage(dialogImage, x1, y1 - 5);
      if (i >= 0 && i < maxSize) {
        LGradation.getInstance(Color.white, Color.black, getWidth() + 6, getSpace())
            .drawHeight(g, x1 + 14, y1 + getSpace() * getDrawContent() + 2);
        g.setColor(Color.darkGray);
        g.drawRect(x1 + 14, y1 + getSpace() * getDrawContent() + 2, getWidth() + 6, getSpace());
      }

      int index = 0;
      // 遍历文字与颜色信息
      for (; ; ) {
        if (index >= maxSize) {
          break;
        }
        int viewIndex = index + view;
        if (viewIndex >= choice.length) {
          break;
        }
        Color nColor;
        if (colors[viewIndex] != null) {
          nColor = colors[viewIndex];
        } else {
          nColor = Color.white;
        }
        int i1 = 0;
        for (int j1 = 0; j1 < choice[viewIndex].length; j1++) {
          g.drawStyleString(
              choice[viewIndex][j1],
              posX + i1 + 14,
              posY + index * getSpace() + getHeight(),
              Color.darkGray,
              nColor);
          i1 += mesList[j1] + tab;
        }
        index++;
      }
    } finally {
      g.setFont(font);
    }
  }
コード例 #4
0
ファイル: AVGScreen.java プロジェクト: wuyun1/loon-simple
 public final void paint(LGraphics g) {
   if (!running || isClose()) {
     return;
   }
   if (sleep == 0) {
     if (scrCG == null) {
       return;
     }
     if (scrCG.getBackgroundCG() != null) {
       if (shakeNumber > 0) {
         g.drawImage(
             scrCG.getBackgroundCG(),
             shakeNumber / 2 - LSystem.random.nextInt(shakeNumber),
             shakeNumber / 2 - LSystem.random.nextInt(shakeNumber));
       } else {
         g.drawImage(scrCG.getBackgroundCG(), 0, 0);
       }
     }
     int moveCount = 0;
     for (int i = 0; i < scrCG.getCharas().size(); i++) {
       Chara chara = (Chara) scrCG.getCharas().get(i);
       float value = 1.0f;
       if (chara.next()) {
         value = chara.getNextAlpha();
         moveCount++;
       }
       g.setAlpha(value);
       chara.draw(g);
       g.setAlpha(1.0F);
     }
     drawScreen(g);
     if (desktop != null) {
       desktop.createUI(g);
     }
     if (sprites != null) {
       sprites.createUI(g);
     }
   } else {
     sleep--;
     if (color != null) {
       double alpha = (double) (sleepMax - sleep) / sleepMax;
       if (alpha < 1.0) {
         if (scrCG.getBackgroundCG() != null) {
           g.drawImage(scrCG.getBackgroundCG(), 0, 0);
         }
         g.setAlpha(alpha);
         g.setColor(color);
         g.fillRect(0, 0, getCurrentWidth(), getCurrentHeight());
         g.setAlpha(1.0f);
       }
     }
     if (sleep <= 0) {
       sleep = 0;
       color = null;
     }
   }
 }
コード例 #5
0
 public void createUI(LGraphics g, int nx, int ny, int x, int y, int w, int h) {
   if (!visible) {
     return;
   }
   Color oldColor = g.getColor();
   g.translate(nx, ny);
   if (alpha > 0.1 && alpha < 1.0) {
     g.setAlpha(alpha);
     g.setColor(color);
     g.fillRect(x, y, w, h);
     g.setAlpha(1.0F);
   } else {
     g.setColor(color);
     g.fillRect(x, y, w, h);
   }
   g.translate(-nx, -ny);
   g.setColor(oldColor);
 }
コード例 #6
0
 public void draw(LGraphics g, int x, int y, int w, int h) {
   switch (style) {
     case 0:
       Color oldColor = g.getColor();
       g.setAntiAlias(true);
       g.setColor(color);
       float alpha = 0.0f;
       int nx = x + w / 2 - (int) r * 4, ny = y + h / 2 - (int) r * 4;
       g.translate(nx, ny);
       for (Iterator it = list.iterator(); it.hasNext(); ) {
         Shape s = (Shape) it.next();
         alpha = isRunning ? alpha + 0.1f : 0.5f;
         g.setAlpha(alpha);
         g.fill(s);
       }
       g.setAntiAlias(false);
       g.setAlpha(1.0F);
       g.translate(-nx, -ny);
       g.setColor(oldColor);
       break;
     case 1:
       g.translate(x, y);
       g.setAntialiasAll(true);
       g.setColor(fill);
       g.drawRect(0, 0, width, height);
       g.setStroke(stroke);
       int sa = angle % 360;
       g.setPaint(border);
       g.drawArc(
           x + (width - paintWidth) / 2,
           y + (height - paintHeight) / 2,
           paintWidth,
           paintHeight,
           sa,
           sa + ANGLE_STEP);
       g.setAntialiasAll(false);
       g.translate(-x, -y);
       break;
   }
 }
コード例 #7
0
 /**
  * 创建默认的选择器背景图片
  *
  * @param w
  * @param h
  * @return
  */
 private LImage createDefaultDialog(int w, int h) {
   if (lazyDialog == null) {
     lazyDialog = new HashMap<String, LImage>(10);
   }
   int hash = 1;
   hash = LSystem.unite(hash, w);
   hash = LSystem.unite(hash, h);
   String key = String.valueOf(hash);
   LImage o = (LImage) lazyDialog.get(key);
   if (o == null) {
     o = LImage.createImage(w, h, true);
     LGraphics g = o.getLGraphics();
     LGradation.getInstance(Color.white, Color.black, w, h).drawHeight(g, 0, 0);
     g.setColor(Color.black);
     g.drawRect(0, 0, w - 1, h - 1);
     g.dispose();
     lazyDialog.put(key, o);
   }
   return o;
 }
コード例 #8
0
ファイル: GIFDecoder.java プロジェクト: wuyun1/loon-simple
 protected void setPixels() {
   int[] dest = image.getPixels();
   if (lastDispose > 0) {
     if (lastDispose == 3) {
       int n = frameCount - 2;
       if (n > 0) {
         lastImage = getFrame(n - 1);
       } else {
         lastImage = null;
       }
     }
     if (lastImage != null) {
       int[] prev = lastImage.getPixels();
       image.setPixels(prev, width, height);
       if (lastDispose == 2) {
         LGraphics g = image.getLGraphics();
         Color c = null;
         if (transparency) {
           c = new Color(0, 0, 0, 0);
         } else {
           c = new Color(lastBgColor);
         }
         g.setColor(c);
         g.fill(lastRect);
         g.dispose();
       }
     }
   }
   int pass = 1;
   int inc = 8;
   int iline = 0;
   for (int i = 0; i < ih; i++) {
     int line = i;
     if (interlace) {
       if (iline >= ih) {
         pass++;
         switch (pass) {
           case 2:
             iline = 4;
             break;
           case 3:
             iline = 2;
             inc = 4;
             break;
           case 4:
             iline = 1;
             inc = 2;
         }
       }
       line = iline;
       iline += inc;
     }
     line += iy;
     if (line < height) {
       int k = line * width;
       int dx = k + ix;
       int dlim = dx + iw;
       if ((k + width) < dlim) {
         dlim = k + width;
       }
       int sx = i * iw;
       while (dx < dlim) {
         int index = ((int) pixels[sx++]) & 0xff;
         int c = act[index];
         if (c != 0) {
           dest[dx] = c;
         }
         dx++;
       }
     }
   }
   image.setPixels(dest, width, height);
 }