Closed Grahack closed 9 years ago
We need to know which version of Processing, OS, and renderer. Please provide this information and a short code example to test.
Might be related to #2339.
See also https://github.com/processing/processing/wiki/Troubleshooting#color0-0-0-0-is-black
may also be related to: https://github.com/processing/processing/issues/3317 which is fixed for next processing
Sorry for the lack of details. It happens with processing.js 1.4.8 and processing 2.2.1 (on my Debian box processing-java says 0227).
Here is a snippet:
void setup() {
size(200, 200);
fill(color(0, 0, 0, 0));
rect(50, 50, 100, 100);
}
Strangely enough, color(1, 0, 0, 0)
is transparent.
See it live here: http://www.openprocessing.org/sketch/204197
processing.js is a separate project that is no longer being developed, and we can't support it here. See: processingjs.org
The open processing link you sent actually looks correct to me: the rect is transparent.
Also, Processing 2.2.1 is not supported at this point; please test with the latest 3.0 alpha. We want to fix things for 3.0.
Why are you using color()
to calculate a color
value for fill()
? I think you're right that this should technically work, but instead of this:
fill(color(0, 0, 0, 0));
why not use this?
fill(0, 0, 0, 0);
For example, in the latest 3.0 alpha, this renders as expected (transparent rect):
void setup() {
size(200, 200);
fill(0, 0, 0, 0);
rect(50, 50, 100, 100);
}
Actually, this is the problem described here: https://github.com/processing/processing/wiki/Troubleshooting#color0-0-0-0-is-black
The reason this doesn't work is that color(0, 0, 0, 0) creates an int that is simply '0'. Which means that fill(color(0, 0, 0, 0)) is the same as fill(0), which is...black. This is a problem of 'color' not being a real type, but just an int, plus the fact that we overload fill() to use both int/color for a color, and also an int for a gray. Since this is unlikely to be fixed anytime soon (if ever) ...
Thanks, @aengelke.
Thanks all, and sorry for the noise. Happy hacking!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Or am I missing something?
Thanks.