|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I've done a bit of digging around and I can't seem to come up with anything.
What I'm trying to do is use HTML colours instead of RGB values. This is
really for ease of programming, to save me having to split and recalculate
the HTML values into RGB. I don't mind doing it, but is there an option to
supply POV with HTML values? Or will it need a conversion script somewhere?
Thanks,
David
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> What I'm trying to do is use HTML colours instead of RGB values.
You should search this newsgroup (povray.newusers) for the topic "RGB<->HEX"
which was posted on 9/9/2004 8:33 PM.
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it David Robinson who wrote:
>I've done a bit of digging around and I can't seem to come up with anything.
>
>What I'm trying to do is use HTML colours instead of RGB values. This is
>really for ease of programming, to save me having to split and recalculate
>the HTML values into RGB. I don't mind doing it, but is there an option to
>supply POV with HTML values? Or will it need a conversion script somewhere?
If you mean HTML codes like "FF0088", then it's possible to write a
macro. It's not particularly pretty because you've got to perform
arithmetic on the contents of strings.
#macro HTMLRGB(H)
#local C=0;
#while (strlen(H)>0)
#local A=substr(H,1,1);
#local H=substr(H,2,strlen(H)-1);
#if (strcmp(A,"0")=0) #local C=C*16; #end
#if (strcmp(A,"1")=0) #local C=C*16+1; #end
#if (strcmp(A,"2")=0) #local C=C*16+2; #end
#if (strcmp(A,"3")=0) #local C=C*16+3; #end
#if (strcmp(A,"4")=0) #local C=C*16+4; #end
#if (strcmp(A,"5")=0) #local C=C*16+5; #end
#if (strcmp(A,"6")=0) #local C=C*16+6; #end
#if (strcmp(A,"7")=0) #local C=C*16+7; #end
#if (strcmp(A,"8")=0) #local C=C*16+8; #end
#if (strcmp(A,"9")=0) #local C=C*16+9; #end
#if (strcmp(A,"A")=0 | strcmp(A,"a")=0) #local C=C*16+10; #end
#if (strcmp(A,"B")=0 | strcmp(A,"b")=0) #local C=C*16+11; #end
#if (strcmp(A,"C")=0 | strcmp(A,"c")=0) #local C=C*16+12; #end
#if (strcmp(A,"D")=0 | strcmp(A,"d")=0) #local C=C*16+13; #end
#if (strcmp(A,"E")=0 | strcmp(A,"e")=0) #local C=C*16+14; #end
#if (strcmp(A,"F")=0 | strcmp(A,"f")=0) #local C=C*16+15; #end
#end
#local R=int(C/256/256);
#local G=mod(int(C/256),256);
#local B=mod(C,256);
rgb <R,G,B>/255
#end
Use it like
pigment {HTMLRGB("FF0088")}
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike Williams <nos### [at] econymdemoncouk> wrote:
> #local C=0;
> #while (strlen(H)>0)
> #local A=substr(H,1,1);
> #local H=substr(H,2,strlen(H)-1);
> #if (strcmp(A,"0")=0) #local C=C*16; #end
> #if (strcmp(A,"1")=0) #local C=C*16+1; #end
> #if (strcmp(A,"2")=0) #local C=C*16+2; #end
> #if (strcmp(A,"3")=0) #local C=C*16+3; #end
> #if (strcmp(A,"4")=0) #local C=C*16+4; #end
> #if (strcmp(A,"5")=0) #local C=C*16+5; #end
> #if (strcmp(A,"6")=0) #local C=C*16+6; #end
> #if (strcmp(A,"7")=0) #local C=C*16+7; #end
> #if (strcmp(A,"8")=0) #local C=C*16+8; #end
> #if (strcmp(A,"9")=0) #local C=C*16+9; #end
> #if (strcmp(A,"A")=0 | strcmp(A,"a")=0) #local C=C*16+10; #end
> #if (strcmp(A,"B")=0 | strcmp(A,"b")=0) #local C=C*16+11; #end
> #if (strcmp(A,"C")=0 | strcmp(A,"c")=0) #local C=C*16+12; #end
> #if (strcmp(A,"D")=0 | strcmp(A,"d")=0) #local C=C*16+13; #end
> #if (strcmp(A,"E")=0 | strcmp(A,"e")=0) #local C=C*16+14; #end
> #if (strcmp(A,"F")=0 | strcmp(A,"f")=0) #local C=C*16+15; #end
> #end
> #local R=int(C/256/256);
> #local G=mod(int(C/256),256);
> #local B=mod(C,256);
> rgb <R,G,B>/255
> #end
Code repetition is one of the biggest sins in programming.
How about this (it has the advantage to support both uppercase and
lowercase hexadecimal numbers, ie. "c2Ab0F" is ok):
#macro HTMLRGB(H)
#local value = 0;
#local len = strlen(H);
#local index = 1;
#while(index <= len)
#local char = asc(substr(H, index, 1)) - 48;
#if(char > 9) #local char = char - 7; #end
#if(char > 15) #local char = char - 32; #end
#local value = value*16 + char;
#local index = index + 1;
#end
<int(value/65536), mod(int(value/256), 256), mod(value,256)>
#end
--
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it Warp who wrote:
>
> Code repetition is one of the biggest sins in programming.
>
> How about this (it has the advantage to support both uppercase and
>lowercase hexadecimal numbers, ie. "c2Ab0F" is ok):
Looks good, and only needs a couple of tiny fixes for it to give the
correct results.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Looks good, and only needs a couple of tiny fixes for it to give the
> correct results.
Like what?
I know it gives garbage if you give it something else than a hex number,
but I assumed the input is always ok.
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Warp" <war### [at] tagpovrayorg> wrote in message
news:4186b975@news.povray.org...
> Mike Williams <nos### [at] econymdemoncouk> wrote:
> > Looks good, and only needs a couple of tiny fixes for it to give the
> > correct results.
>
> Like what?
>
> I know it gives garbage if you give it something else than a hex number,
> but I assumed the input is always ok.
>
Just this:
rgbf<int(value/65536), mod(int(value/256), 256), mod(value,256)>
Thanks a lot though, great script, works beautifully :)
David
[learning something new every day]
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"David Robinson" <tdf### [at] ezrscom> wrote in message
news:4187b634$1@news.povray.org...
> "Warp" <war### [at] tagpovrayorg> wrote in message
> news:4186b975@news.povray.org...
> > Mike Williams <nos### [at] econymdemoncouk> wrote:
> > > Looks good, and only needs a couple of tiny fixes for it to give the
> > > correct results.
> >
> > Like what?
> >
> > I know it gives garbage if you give it something else than a hex
number,
> > but I assumed the input is always ok.
> >
> Just this:
>
> rgbf<int(value/65536), mod(int(value/256), 256), mod(value,256)>
>
> Thanks a lot though, great script, works beautifully :)
>
No wait, I got that wrong. After running a few values through, a lot of
colours seem to come out as white, so it must be a maths thing...?
David
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
David Robinson <tdf### [at] ezrscom> wrote:
> No wait, I got that wrong. After running a few values through, a lot of
> colours seem to come out as white, so it must be a maths thing...?
That's because there really was a bug in my code. I forgot a /255.
The last line should be:
<int(value/65536), mod(int(value/256), 256), mod(value,256)>/255
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|