private ImagePanel getGraph1Panel() {
   if (graph1Panel == null && graph1RootPanel != null) {
     int width = graph1RootPanel.getWidth();
     int height = graph1RootPanel.getHeight();
     SimpleImage img = new SimpleImage(width, height);
     img.fillBackground(0, 0, 0);
     graph1Panel = new ImagePanel(img, 0, 0, graph1RootPanel.getWidth());
     graph1RootPanel.add(graph1Panel, BorderLayout.CENTER);
     graph1RootPanel.getParent().validate();
     graph1RootPanel.repaint();
   }
   return graph1Panel;
 }
 private FlamePanel getPoolPreviewFlamePanel() {
   if (poolFlamePreviewFlamePanel == null && poolFlamePreviewPnl != null) {
     int width = poolFlamePreviewPnl.getWidth();
     int height = poolFlamePreviewPnl.getHeight();
     SimpleImage img = new SimpleImage(width, height);
     img.fillBackground(0, 0, 0);
     poolFlamePreviewFlamePanel =
         new FlamePanel(prefs, img, 0, 0, poolFlamePreviewPnl.getWidth(), poolFlameHolder, null);
     poolFlamePreviewFlamePanel.setRenderWidth(640);
     poolFlamePreviewFlamePanel.setRenderHeight(480);
     poolFlamePreviewFlamePanel.setDrawTriangles(false);
     poolFlamePreviewPnl.add(poolFlamePreviewFlamePanel, BorderLayout.CENTER);
     poolFlamePreviewPnl.getParent().validate();
     poolFlamePreviewPnl.repaint();
   }
   return poolFlamePreviewFlamePanel;
 }
 private FlamePanel getFlamePanel() {
   if (flamePanel == null && flameRootPanel != null) {
     int borderWidth = flameRootPanel.getBorder().getBorderInsets(flameRootPanel).left;
     int width = flameRootPanel.getWidth() - borderWidth;
     int height = flameRootPanel.getHeight() - borderWidth;
     if (width < 16 || height < 16) return null;
     SimpleImage img = new SimpleImage(width, height);
     img.fillBackground(0, 0, 0);
     flamePanel =
         new FlamePanel(prefs, img, 0, 0, flameRootPanel.getWidth() - borderWidth, null, null);
     flamePanel.setRenderWidth(640);
     flamePanel.setRenderHeight(480);
     flameRootPanel.add(flamePanel, BorderLayout.CENTER);
     flameRootPanel.getParent().validate();
     flameRootPanel.repaint();
   }
   flamePanel.setFlameHolder(renderThread);
   return flamePanel;
 }
Пример #4
0
 @Override
 protected void performImageTransformation(WFImage pImg) {
   SimpleImage img = (SimpleImage) pImg;
   if ((leftSize > 0) || (topSize > 0) || (rightSize > 0) || (bottomSize > 0)) {
     PlainImageCreator creator = new PlainImageCreator();
     creator.setBgColor(color);
     SimpleImage bgImg =
         creator.createImage(
             pImg.getImageWidth() + leftSize + rightSize,
             pImg.getImageHeight() + topSize + bottomSize);
     ComposeTransformer cT = new ComposeTransformer();
     cT.setForegroundImage(img);
     cT.setLeft(leftSize);
     cT.setTop(topSize);
     cT.setGenlock(ComposeTransformer.Genlock.NONE);
     cT.setHAlign(ComposeTransformer.HAlignment.OFF);
     cT.setVAlign(ComposeTransformer.VAlignment.OFF);
     cT.transformImage(bgImg);
     img.setBufferedImage(bgImg.getBufferedImg(), bgImg.getImageWidth(), bgImg.getImageHeight());
   }
 }
Пример #5
0
  @Override
  protected void fillImage(SimpleImage res) {
    int width = res.getImageWidth();
    int height = res.getImageHeight();
    Random rnd = new Random();
    rnd.setSeed(this.seed);
    double cover = 1.0 - this.cover;
    double aspect = (double) width / (double) height;
    int frequency = this.initialFrequency;
    int frequencyX = (int) (frequency * aspect + 0.5);
    int frequencyY = (int) (frequency * aspect + 0.5);
    double alphaInt = 1.0f;
    BufferedImage mainImage = res.getBufferedImg();
    Graphics2D mainGr = mainImage.createGraphics();

    for (int i = 0; i < this.octaves; i++) {
      // create a small random image
      BufferedImage rndMap = new BufferedImage(frequencyX, frequencyY, BufferedImage.TYPE_INT_ARGB);
      {
        Graphics2D g = rndMap.createGraphics();
        try {
          switch (colorMode) {
            case COLOR:
              for (int x = 0; x < frequencyX; x++) {
                for (int y = 0; y < frequencyY; y++) {
                  int rVal = rnd.nextInt(255);
                  int gVal = rnd.nextInt(255);
                  int bVal = rnd.nextInt(255);
                  g.setColor(new Color(rVal, gVal, bVal, (int) (255.0 * alphaInt + 0.5)));
                  g.fillRect(x, y, 1, 1);
                }
              }
              break;
            case GREY:
              for (int x = 0; x < frequencyX; x++) {
                for (int y = 0; y < frequencyY; y++) {
                  int val = rnd.nextInt(255);
                  g.setColor(new Color(val, val, val, (int) (255.0 * alphaInt + 0.5)));
                  g.fillRect(x, y, 1, 1);
                }
              }
              break;
            case BASE_COLOR:
              int rBase = this.cloudColor.getRed();
              int gBase = this.cloudColor.getGreen();
              int bBase = this.cloudColor.getBlue();
              for (int x = 0; x < frequencyX; x++) {
                for (int y = 0; y < frequencyY; y++) {
                  int val = rnd.nextInt(255);
                  int rVal = (rBase * val) / 255;
                  int gVal = (gBase * val) / 255;
                  int bVal = (bBase * val) / 255;
                  g.setColor(new Color(rVal, gVal, bVal, (int) (255.0 * alphaInt + 0.5)));
                  g.fillRect(x, y, 1, 1);
                }
              }
              break;
          }
        } finally {
          g.dispose();
        }
      }
      // scale up the image using Java-built-in interpolation
      {
        BufferedImage scaledRndMap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = scaledRndMap.createGraphics();
        try {
          g.setRenderingHint(
              RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
          g.drawImage(rndMap, 0, 0, width, height, 0, 0, frequencyX, frequencyY, null);
        } finally {
          g.dispose();
        }
        mainGr.drawImage(scaledRndMap, null, 0, 0);
      }
      alphaInt *= this.persistence;
      frequency += frequency;
      frequencyX = (int) (frequency * aspect + 0.5);
      frequencyY = (int) (frequency * aspect + 0.5);
    }
    // apply an exponential filter to let the noise more look like clouds
    if (mode == Mode.CLOUDS) {
      final double rWeight = 0.2990;
      final double gWeight = 0.5880;
      final double bWeight = 0.1130;
      SimpleImage bgImg = (this.backgroundImg != null) ? backgroundImg.getImage() : null;
      Pixel pixel = new Pixel();
      Pixel bgPixel = new Pixel();
      for (int i = 0; i < mainImage.getWidth(); i++) {
        for (int j = 0; j < mainImage.getHeight(); j++) {
          pixel.setARGBValue(res.getARGBValue(i, j));
          double lum = pixel.r * rWeight + pixel.g * gWeight + pixel.b * bWeight;
          double c = lum - (cover * 255);
          if (c < 0) c = 0;
          int iVal = Tools.roundColor(255.0 - (Math.pow(this.sharpness, c) * 255.0));
          int bgRed = 0, bgGreen = 0, bgBlue = 0;
          switch (bgMode) {
            case IMAGE:
              if (bgImg != null) {
                bgPixel.setARGBValue(bgImg.getARGBValueIgnoreBounds(i, j));
                bgRed = bgPixel.r;
                bgGreen = bgPixel.g;
                bgBlue = bgPixel.b;
              }
              break;
            case COLOR:
              bgRed = this.bgColor.getRed();
              bgGreen = this.bgColor.getGreen();
              bgBlue = this.bgColor.getBlue();
              break;
          }
          switch (colorMode) {
            case GREY:
              pixel.r = expose(iVal + 1.5 * bgRed);
              pixel.g = expose(iVal + 1.5 * bgGreen);
              pixel.b = expose(iVal + 1.5 * bgBlue);
              break;
            default:
              pixel.r = expose((iVal * pixel.r) / 255 + 1.5 * bgRed);
              pixel.g = expose((iVal * pixel.g) / 255 + 1.5 * bgGreen);
              pixel.b = expose((iVal * pixel.b) / 255 + 1.5 * bgBlue);
              break;
          }
          res.setRGB(i, j, pixel);
        }
      }
    }
  }