I have an element in my model that uses the color transform, and I want to specify the alpha parameter using a variable. However, it only seems to work if I use a literal. If I do the following:
color("Red",0.25)…
Everything works as expected. However, if I use a variable:
opacity=0.25;
color("Red",opacity)…
Then it acts as if I did not specify an alpha parameter (or an alpha parameter with value 1.0). Why am I not allowed to use a variable for the alpha parameter of the color transform? Thanks.
Nathan Sokalski
njsokalski@hotmail.commailto:njsokalski@hotmail.com
On Thu, 2024-05-30 at 19:29 +0000, Nathan Sokalski via Discuss wrote:
I have an element in my model that uses the color transform, and I
want to specify the alpha parameter using a variable. However, it
only seems to work if I use a literal. If I do the following:
color("Red",0.25)…
Everything works as expected. However, if I use a variable:
opacity=0.25;
color("Red",opacity)…
Then it acts as if I did not specify an a2024.03.02.ai18721lpha
parameter (or an alpha parameter with value 1.0). Why am I not
allowed to use a variable for the alpha parameter of the color
transform? Thanks.
Works fine for me.
dingus=.50;
sphere(10);
color("Red",dingus) cube (50);
This does exactly what I expect.
It may depend on the rev level.
I am using OpenSCAD version 2024.03.02.ai18721
On 5/30/2024 2:34 PM, larry via Discuss wrote:
On Thu, 2024-05-30 at 19:29 +0000, Nathan Sokalski via Discuss wrote:
I have an element in my model that uses the color transform, and I
want to specify the alpha parameter using a variable. However, it
only seems to work if I use a literal. If I do the following:
color("Red",0.25)…
Everything works as expected. However, if I use a variable:
opacity=0.25;
color("Red",opacity)…
Then it acts as if I did not specify an a2024.03.02.ai18721lpha
parameter (or an alpha parameter with value 1.0). Why am I not
allowed to use a variable for the alpha parameter of the color
transform? Thanks.
Works fine for me.
dingus=.50;
sphere(10);
color("Red",dingus) cube (50);
This does exactly what I expect.
It may depend on the rev level.
I am using OpenSCAD version 2024.03.02.ai18721
It's almost inconceivable that there could be such a misbehavior, in any
version. Modules (including built-in ones) simply have no visibility
into whether their arguments are constants or more general expressions.
(Well, OK, maybe they could go out of their way to tell the difference,
but they would have to do extra work.)
I tried Larry's example in 2021.01, 2023.12.31, and 2024.03.05. It
worked in all of them.
Nathan, you need to supply a more complete demonstration.