Code Search for Developers
 
 
  

LogarithmicPalette.java from GridBlocks at Krugle


Show LogarithmicPalette.java syntax highlighted

package mandelbrot.ui;

import java.awt.Color;

/**
 * The LogarithmicPalette class includes 256 colors. The first colors (indices 0..200) are dominantly blue and the
 * rest lose their blue component very rapidly. Hence they are hues of yellow.
 */
public class LogarithmicPalette
{
    private Color color[];


    /**
     * The constructor.
     */
    public LogarithmicPalette()
    {
        int level;
        double colfactor = 255.0 / Math.log((double) (255 + 1));
        color = new Color[255];

        /* The idea is to decrease the blue component logarithmically.
         * This means that the blue component decreases rapidly at high index values (220--255).
         * This produces a nice visual effect when used with fractals.
         */
        for (int n = 0; n < 255; n++)
        {
            level = (int) (colfactor * Math.log(n + 1));
            color[n] = new Color(level, level, 255 - level);
        }
    }


    public Color getColor(int i)
    {
        return color[i];
    }
}




See more files for this project here

GridBlocks

GridBlocks builds a grid application framework via easy-to-use building blocks in distributed environment. The framework offers components for Grid security, distributed storage, computing, and Portlet web interfaces.

Project homepage: http://sourceforge.net/projects/gridblocks
Programming language(s): Java,JSP,XML
License: other

  ImagePanel.java
  LogarithmicPalette.java
  MandelbrotSurfer.java