POV-Ray : Newsgroups : povray.binaries.images : Crackle - are we bored yet? : Re: Crackle - are we bored yet? Server Time
28 Mar 2024 17:34:51 EDT (-0400)
  Re: Crackle - are we bored yet?  
From: kurtz le pirate
Date: 3 Dec 2022 13:22:47
Message: <638b93f7$1@news.povray.org>
On 03/12/2022 16:07, Bald Eagle wrote:
> kurtz le pirate <kur### [at] gmailcom> wrote:
> 
>> LOL !
>> 2.2.1.6 User-Defined Functions
>> ...Excluded are for example strlen or vlength...
> 
> Ugh.   I hate that.
> // Length or Norm
> #declare Vlength = function (ax, ay, az) {sqrt(ax*ax + ay*ay + az*az)}
> 
> Take that, POV-Ray, function parser!
> 

Don't worry about the Vlength, I had corrected it myself.
But it's funny that your example falls on an unauthorized function.


I'm moving slowly but I think I've seen too much complication all at
once. I made this :

plane {
 y, 0
 pigment {
  function {
   hsl2rgb ( << selected line for the error
    fnHue(x,z),
    Saturation,
    fnLightness(x,z)
    )
   }
  }
 }

and i get this error : Float expected but vector or color expression found.

I made this (very very simplified complex representation) :
#declare fnHue = function(re,im) { mod(degrees(atan2(im,re)),360) }
#declare fnLightness = function(re,im) { sqrt(re*re+im*im) }
#declare Saturation = 1.0;


'hsl2rgb' is a small macro that converts HSL to RGB from
<https://www.rapidtables.com/convert/color/hsl-to-rgb.html>

#macro hsl2rgb (H,S,L)
 #local C=(1-abs(2*L-1))*S;
 #local X=C*(1-abs(mod(H/60,2)-1));
 #local m=L-(C/2);
 #local l = 0.99999999;
 #switch (H)
  #range (0,60*l)
   #local r=<C,X,0>;
  #break
  #range (60,120*l)
   #local r=<X,C,0>;
  #break
  #range (120,180*l)
   #local r=<0,C,X>;
  #break
  #range (180,240*l)
   #local r=<0,X,C>;
  #break
  #range (240,300*l)
   #local r=<X,0,C>;
  #break
  #range (300,360*l)
   #local r=<C,0,X>;
  #break
 #end
 r*m
#end


Why this "Float expected but vector or color expression" ?
I still have a lot to learn ...




-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

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