Color Gradient For Mandelbrot Android Application Doesn't Work
I'm trying to to program the Mandelbrot set for Android. I try to draw it on a Canvas. It works, but I want to have a color gradient. This is my code: package de.turbofractal; imp
Solution 1:
paint.setARGB(255,0,0,Math.round((n/g)*255));
The arguments for setARGB
are a
lpha, r
ed, g
reen, and b
lue - you are only supplying values to the alpha and blue parameters.
Inside the b
parameter, both n
and g
are integer parameters, so when you divide them, you will get an integer result, not a double. (See "Java Integer Division, How do you produce a double?") This means you only get the whole number part of the result, which isn't what you want. Cast n
or g
to a double and it should work.
Post a Comment for "Color Gradient For Mandelbrot Android Application Doesn't Work"