Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » why does infinity color return grayscale?
- Crow_Boy08
-
1000+ posts
why does infinity color return grayscale?
set [color v] effect to (join [] [infinity])
- medians
-
1000+ posts
why does infinity color return grayscale?
..You guys have fun..

Also probably just to return grayscale since they wanted a workaround for it. That's probably my only guess LOL

Also probably just to return grayscale since they wanted a workaround for it. That's probably my only guess LOL
- Crow_Boy08
-
1000+ posts
why does infinity color return grayscale?
.
Last edited by Crow_Boy08 (Jan. 8, 2023 04:19:18)
- medians
-
1000+ posts
why does infinity color return grayscale?
Yea and not being able to memorate the raccoon potato..your pain is epilepsy ..You guys have fun..
Also probably just to return grayscale since they wanted a workaround for it. That's probably my only guess LOL

AHHH
Yeah, higher values don’t even turn it black/grey, yet 1/0 does LOL.
- ScratchCreatesIt
-
7 posts
why does infinity color return grayscale?
Here's my guess, since the number is too high, Scratch isn't able to perfectly divide by 100 (that's the scale) and so it turns black and white.
Let me know if you know the answer!
Let me know if you know the answer!

- -Valtren-
-
1000+ posts
why does infinity color return grayscale?
it's an error last I checked.
- jlnilocalsip
-
100+ posts
why does infinity color return grayscale?
Jesus everloving Christ, this bug needs to be fixed immediately for the good and wellbeing of all Scratchers.
- -Valtren-
-
1000+ posts
why does infinity color return grayscale?
then how are we supposed to get greyscale? also it's not as if this harms anyone Jesus everloving Christ, this bug needs to be fixed immediately for the good and wellbeing of all Scratchers.
- hi875230163394
-
1000+ posts
why does infinity color return grayscale?
1/0 returns infinity, it also does this in JS Yeah, higher values don’t even turn it black/grey, yet 1/0 does LOL.
the question is, was this intentional, and did it exist before 3.0 started using JS
- Maximouse
-
1000+ posts
why does infinity color return grayscale?
Scratch 2.0 was written in ActionScript, a JS dialect, so infinity worked the same way. It didn't break the color effect though, so I think the 3.0 behavior is a bug.1/0 returns infinity, it also does this in JS Yeah, higher values don’t even turn it black/grey, yet 1/0 does LOL.
the question is, was this intentional, and did it exist before 3.0 started using JS
- -HatsuMiku-
-
30 posts
why does infinity color return grayscale?
If anything, it actually benefits them.then how are we supposed to get greyscale? also it's not as if this harms anyone Jesus everloving Christ, this bug needs to be fixed immediately for the good and wellbeing of all Scratchers.
- awesome-llama
-
1000+ posts
why does infinity color return grayscale?
I can guess by looking at the code…
I haven't gone to the length of running it or debugging it, I am only reading it and guessing what the functions are doing with certain data.
One of the places that the effect blocks are implemented is in the sprite fragment shader.
https://github.com/LLK/scratch-render/blob/develop/src/shaders/sprite.frag
Here's the line responsible for changing hue and also setting the RGB colour afterwards. (hsv is a 3D vector here and the x component would be hue, u_color is the value from the colour effect)
I assume what's happening is the modulo operator is not able to handle Infinity and so it returns something that ends up affecting the HSV to RGB conversion afterwards in an unexpected way.
Also here's the conversion code:
I haven't gone to the length of running it or debugging it, I am only reading it and guessing what the functions are doing with certain data.
One of the places that the effect blocks are implemented is in the sprite fragment shader.
https://github.com/LLK/scratch-render/blob/develop/src/shaders/sprite.frag
Here's the line responsible for changing hue and also setting the RGB colour afterwards. (hsv is a 3D vector here and the x component would be hue, u_color is the value from the colour effect)
hsv.x = mod(hsv.x + u_color, 1.0); if (hsv.x < 0.0) hsv.x += 1.0; gl_FragColor.rgb = convertHSV2RGB(hsv);
I assume what's happening is the modulo operator is not able to handle Infinity and so it returns something that ends up affecting the HSV to RGB conversion afterwards in an unexpected way.
Also here's the conversion code:
vec3 convertHue2RGB(float hue) { float r = abs(hue * 6.0 - 3.0) - 1.0; float g = 2.0 - abs(hue * 6.0 - 2.0); float b = 2.0 - abs(hue * 6.0 - 4.0); return clamp(vec3(r, g, b), 0.0, 1.0); } vec3 convertHSV2RGB(vec3 hsv) { vec3 rgb = convertHue2RGB(hsv.x); float c = hsv.z * hsv.y; return rgb * c + hsv.z - c; }
- medians
-
1000+ posts
why does infinity color return grayscale?
Yea I don’t think so.1/0 returns infinity, it also does this in JS Yeah, higher values don’t even turn it black/grey, yet 1/0 does LOL.
the question is, was this intentional, and did it exist before 3.0 started using JS
Oh it’s the greyscale dude Jesus everloving Christ, this bug needs to be fixed immediately for the good and wellbeing of all Scratchers.
- _Icicle-Cube_
-
500+ posts
why does infinity color return grayscale?
try doing this: don't work.
set [color v] effect to ((1) / (0))as far as I know, that code makes it greayscale.
- Vadik1
-
500+ posts
why does infinity color return grayscale?
People shouldn't use this way of getting greyscale, as it is very unreliable. The results of setting color to infinity differ depending on device and the browser. then how are we supposed to get greyscale? also it's not as if this harms anyone
I tested it on 3 devices and got different results:
Desktop computer running Chromium 107 (greyscale):

Android phone (with Mali-G71 GPU) made in 2019 running Chrome 108 (like greyscale, except it's shades of red):

Android tablet (with Mali-400 MP GPU) made in 2013 running Chrome 81 (slight red tint):

A reliable and better looking way to get greyscale is to have costume, with this same costume overlayed on top with color=100 and ghost=50.
Last edited by Vadik1 (Jan. 13, 2023 15:44:20)
- _Icicle-Cube_
-
500+ posts
why does infinity color return grayscale?
I did it the way you said, and it came out as blue, not greay.People shouldn't use this way of getting greyscale, as it is very unreliable. The results of setting color to infinity differ depending on device and the browser. then how are we supposed to get greyscale? also it's not as if this harms anyone
-snip-
A reliable and better looking way to get greyscale is to have costume, with this same costume overlayed on top with color=100 and ghost=50.
doesn't work, doing
change [color v] effect by ((1)/(0))works though.
- Vadik1
-
500+ posts
why does infinity color return grayscale?
I meant something like:I did it the way you said, and it came out as blue, not greay. …
A reliable and better looking way to get greyscale is to have costume, with this same costume overlayed on top with color=100 and ghost=50.
doesn't work
…

- blablablahello
-
1000+ posts
why does infinity color return grayscale?
I feel like this probably has to do with how the colors are calculated, at infinity, the algorithm probably just thinks “hey, how bout no color at all”
- Vadik1
-
500+ posts
why does infinity color return grayscale?
It returns NaN. I assume what's happening is the modulo operator is not able to handle Infinity and so it returns something that ends up affecting the HSV to RGB conversion afterwards in an unexpected way.
Any mathematical operation with NaN also results in NaN.
When given NaN, “clamp(value, minimum, maximum)” always returns it's minimum value.
It can be verified, by running the following glsl code on https://www.shadertoy.com/new
(pause and then reset animation to time 0, so that iTime is also 0)
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // Clamp turns NaN into it's minimum value float col = clamp(mod(1.0/iTime, 1.0), -1.0, 1.0)+1.5; // col = -1.0+1.5 = 0.5 fragColor = vec4(vec3(col),1.0); // vec(0.5, 0.5, 0.5, 1.0) is grey }
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // Without clamp, NaN leaks and turns everything into NaN float col = mod(1.0/iTime, 1.0)+1.5; // col = NaN+1.5 = NaN, not 1.5 fragColor = vec4(vec3(col),1.0); // vec(NaN, NaN, NaN, 1.0) is black }
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // If it was 1.5 float col = 0.0+1.5; // col = 1.5 fragColor = vec4(vec3(col),1.0); // vec(1.5, 1.5, 1.5, 1.0) is white }
So, in scratch:
mod(hue + Infinity, 1.0) returns NaN
if(hsv.x < 0) doesn't trigger
convertHSV2RGB is called with hsv in which x=NaN
convertHue2RGB is called with hue=NaN
Inside of it, as the result of calculations: r=NaN, g=NaN, b=NaN
Clamping vector of those values to range between 0 and 1 returns vector of 3 zeroes, which is black.
Brightness and saturation are added on top of black, which results in greyscale.
- Discussion Forums
- » Questions about Scratch
-
» why does infinity color return grayscale?