POV-Ray : Newsgroups : povray.newusers : Any help in colors and java convertions ? : Re: Any help in colors and java convertions ? Server Time
6 Dec 2021 16:39:27 EST (-0500)
  Re: Any help in colors and java convertions ?  
From: Le Forgeron
Date: 29 Sep 2019 12:17:29
Message: <5d90d919$1@news.povray.org>
Le 28/09/2019 à 17:35, kurtz le pirate a écrit :
> Hello,
> 
> I'm trying to make pictures of the mandelbrot set. I found several
> examples on the web but I have a problem to adapt the sources.
> 
> Signifiant part of Java code building colors table :
> 
> import java.awt.Color;
> int max = 1000;
> int[] colors = new int[max];
> for (int i = 0; i<max; i++) {
>   colors[i] = Color.HSBtoRGB(i/256f, 1, i/(i+8f));
>   }
> 

Beware, HSBtoRGB truncate the H part to keep only the part after the
decimal point, multiply it by 360 to get the Hue.


> Displaying "colors" table give :
>    0 : 0.000000 0.000000 0.000000
>    1 : 0.109804 0.003922 0.000000
>    2 : 0.200000 0.007843 0.000000
>    3 : 0.274510 0.019608 0.000000
>    4 : 0.333333 0.031373 0.000000
>    5 : 0.384314 0.043137 0.000000
>    6 : 0.427451 0.058824 0.000000
>    7 : 0.466667 0.078431 0.000000
>    8 : 0.501961 0.094118 0.000000
>    ...
>    ...
> 
> 
> Trying to do in POVRay :
> #include "colors.inc"
> #declare Max = 1000;
> #declare ColorsArray = array[Max];
> #declare i=0;
> #while(i<Max)
>   #declare ColorsArray[i] = CHSL2RGB(<i/256, 1, i/(i+8)>);
>   #declare i=i+1;
> #end
> 
> "ColorsArray" give :
>    0 : 0.000000 0.000000 0.000000
>    1 : 0.222222 0.003704 0.000000
>    2 : 0.400000 0.013333 0.000000
>    3 : 0.545455 0.027273 0.000000
>    4 : 0.666667 0.044444 0.000000
>    5 : 0.769231 0.064103 0.000000
>    6 : 0.857143 0.085714 0.000000
>    7 : 0.933333 0.108889 0.000000
>    8 : 1.000000 0.133333 0.000000
>    ...
> 
> 
> he result is very different and, of course, the image does
> not give the same thing... iI suspect the value 'hue' passed to the
> macro, but after several attempts I can't do it (i/360, i*360/max,...)
> 

for Hue, the macro expect something between 0 to 360, so adaptation
would be :
CHSL2RGB( < 360*i/256, 1, i/(i+8) > )


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.