我有一个函数可以在[0-255]
. 计算后,我借助预生成的调色板绘制结果,该调色板也有 256 个值。
计算:
int MAX = 255;
private int calculateMandel(double positionX, double positionY) {
int valueOne = 0;
double complexReal = 0.0;
double complexImaginery = 0.0;
double complexRealSquare = 0.0;
double complexImaginerySquare = 0.0;
while (valueOne < MAX && complexRealSquare + complexImaginerySquare < 4.0) {
complexImaginery = 2.0 * complexReal * complexImaginery + positionY;
complexReal = complexRealSquare - complexImaginerySquare + positionX;
complexRealSquare = complexReal * complexReal;
complexImaginerySquare = complexImaginery * complexImaginery;
valueOne++;
}
return valueOne;
}
结果:
这显然是一个非常糟糕的渲染,因为可以看到层次,它不够平滑。如何让我的图片更流畅?像这样:http: //upload.wikimedia.org/wikipedia/commons/2/21/Mandel_zoom_00_mandelbrot_set.jpg