Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is alpha treated differently in a while loop? #744

Closed
q2apro opened this issue Jan 16, 2019 · 3 comments
Closed

Why is alpha treated differently in a while loop? #744

q2apro opened this issue Jan 16, 2019 · 3 comments

Comments

@q2apro
Copy link

q2apro commented Jan 16, 2019

Using the function from #739 gives me great wedges/angles using:

anglemark((0,0), 0, 45, cradius, true, (0,0,1), 0.1);
anglemark((0,0), 45, 90, cradius, true, (0,0,1), 0.1);
anglemark((0,0), 90, 135, cradius, true, (0,0,1), 0.1);
// ...

Result:

image

Using a while loop with the same function, however, adds to the alpha value on each loop. Even though the alpha value is the same with 0.1 all the time!

i = 0;
pieces = 16;
pieceangle = 360/pieces;
while(
	i<=pieces,
	anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
	i = i+1;
);

Result:

image

  1. Why is alpha added with each fill() call?
  2. How to have a fixed alpha value?

Thanks in advance!

@q2apro
Copy link
Author

q2apro commented Jan 16, 2019

Update:

It seems that it is not a scope problem, the alpha problem also occurs with this code:

i = 0;
pieceangle = 360/pieces;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;
anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);
i=1+i;

image

@montaga
Copy link
Member

montaga commented Jan 16, 2019

Its not a bug.
You are overpainting something with alpha again and again and therefore it gets more opac. Probably you like something as

anglemark((0,0), i*pieceangle, (i+1)*pieceangle, cradius, true, (0,0,1), 0.1);

instead of

anglemark((0,0), i*pieceangle, pieceangle, cradius, true, (0,0,1), 0.1);

@q2apro
Copy link
Author

q2apro commented Jan 16, 2019

Stupid me 🤦‍♂️

Thank you Aaron!

@q2apro q2apro closed this as completed Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants