i spent a while looking for this, i assume other people have looked for it too so i'm sharing it there's a bug with r = 0 g = 0 b = 0, can't be bothered fixing it
uses actual HSV values. took me like 10 minutes of fiddling, and this only uses one stamp compared to the original. uses an rgb to hsv converter by @Toxic_Pepper, https://scratch.mit.edu/projects/307662334/. I slightly modified it for compactness and to use 0-100 for brightness/saturation