如何在Mandelbrot分形代中平滑外部颜色梯度?

时间:2014-05-11 00:38:10

标签: fractals mandelbrot

这是我在mandelbrot分形世代的进步:

enter image description here

在颜色之间的边缘情况很小的情况下,它具有良好的“混合”效果。但是,随着颜色之间的距离变大,您可以非常明确地看到颜色的分离。我想知道,如果不使用像双三次插值后处理这样的东西,我将如何实现混合效果?

附件是我必须生成分形的代码:

public static void drawFractal()
{
    Complex Z;
    Complex C;

    double x;
    double y;

    // The min and max values should be between -2 and +2
    double minX = -2.0; // use -2 for the full-range fractal image
    double minY = -2.0; // use -2 for the full-range fractal image
    double maxX = 2.0; // use 2 for the full-range fractal image
    double maxY = 2.0; // use 2 for the full-range fractal image

    double xStepSize = ( maxX - minX ) / width;
    double yStepSize = ( maxY - minY ) / height;
    int maxIterations = 100;
    int maxColors = 0xFF0000;

    // for each pixel on the screen
    for( x = minX; x < maxX; x = x + xStepSize)
    {
        for ( y = minY; y < maxY; y = y + yStepSize )
        {
            C = new Complex( x, y );
            Z = new Complex( 0, 0 );
            int iter = getIterValue( Z, C, 0, maxIterations );

            int myX = (int) ( ( x - minX ) / xStepSize );
            int myY = (int) ( ( y - minY ) / yStepSize );
            if ( iter < maxIterations )
            {
                myPixel[ myY * width + myX ] = iter * ( maxColors / maxIterations ) / 50; 
            }
        }
    }
}

0 个答案:

没有答案