osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

Implement ability to get `Texture`'s average colour

Open EVAST9919 opened this issue 2 years ago • 2 comments

Some design elements require sampling colour from the texture. This implementation covers this functionality in the simplest way possible - getting average colour of non-transparent pixels.

However I'm marking this as a draft due to this issue https://github.com/ppy/osu/issues/9307. Basically looks like iterating over pixel data may cause performance issues.

EVAST9919 avatar Dec 07 '23 06:12 EVAST9919

Where is this intended to be used? Also are you sure we want average colour? Generally things like this prefer a smarter algorithm, which picks the accent colours from an image.

peppy avatar Dec 07 '23 06:12 peppy

Where is this intended to be used?

It's used in the song-select for beatmap panels Снимок экрана 2023-12-07 100546

Also are you sure we want average colour? Generally things like this prefer a smarter algorithm, which picks the accent colours from an image.

Smarter algo would be better, yes. But at first I would like to be sure that I'm putting things in the right place (and if so - probably would be better to combine with ComputeOpacity to avoid 2 loops over pixels in worst case scenario). May be we want to expose pixel data somehow and compute the colour osu-side upon request or something?

EVAST9919 avatar Dec 07 '23 07:12 EVAST9919