79457034

Date: 2025-02-21 10:25:00
Score: 0.5
Natty:
Report link

I am very new to this colour space conversion stuff,
and I dont even know if I have the right approach.

Your approach is fine and correct. You're doing a simple mistake of scaling down (the r/g/b values) but then later you don't scale them up for usage in the imgOut part.

Using (r/255) scales it down (or will "normalize" it) from being a value in 0 to 255 range, into now being a value in a 0 to 1 range.

Re-scale it up, into being within 0-255 range like this:

imgOut.pixels[index + 0] = ( 255 * computedC );
imgOut.pixels[index + 1] = ( 255 * computedM );
imgOut.pixels[index + 2] = ( 255 * computedY );
imgOut.pixels[index + 3] = 125;

If the new imgOut colours are not exact:
Then try something like: Math.round( 255 * computedC );

Round down using: imgOut.pixels[index + 0] = Math.floor( 255 * computedC );
Round up using :imgOut.pixels[index + 0] = Math.ceil( 255 * computedC );

Now do you see multiple colours instead of just black?

Reasons:
  • RegEx Blacklisted phrase (1.5): I am very new
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • High reputation (-2):
Posted by: VC.One