- Home /
Get the main colour of a sprite?
Hi,
How would i go about getting the main/most common colour of a sprite? Say I have this sprite:
How would i get the main pink colour from this sprite in code?
Any help is greatly appreciated, thanks.
Answer by Xarbrough · Dec 20, 2015 at 07:24 PM
You first would have to define what "main colour" means. You can simple take the average of all pixels by looping through them, adding the individual color components up and dividing them by the number of pixels. Or you could do other math operations to find something like the median, it really depends on what your want to do with the information.
Your answer
Follow this Question
Related Questions
Loading and creating Sprites at runtime 0 Answers
Changing a second objects material on trigger 0 Answers
Sprite color changes after import 1 Answer
How to change Sprite color with alpha mask? 0 Answers
Unity generate a 2D background 1 Answer