Given a three-byte RGB value I would like to generate a new, random RGB value such that their R + G + B sums are equal.
E.g. (30, 40, 20) has an intensity of 30; 90 / 3. Valid results would include (0, 90, 0), (18, 32, 50), etc.
It might go without saying, I'd like the possible solutions to have equal probability.
It would be neat to do this in O(1), the best I can come up with is to generate a random 3-byte value and randomly manipulate it until the desired intensity is reached.
Aucun commentaire:
Enregistrer un commentaire