haven1433 / HexManiacAdvance

A tool for editing tables, text, scripts, images, and other data in Pokemon GBA games
MIT License
236 stars 55 forks source link

Make gradients smoother #182

Closed PhoenixBound closed 1 year ago

PhoenixBound commented 1 year ago

I saw an issue in the Discord server about gradients and got in the mood to mess around a bit. Not sure whether this is what you're looking for or not, but it was a fun break from script commands.

A "perceptually uniform" color space makes drawing a line between two colors more closely match what it looks like to be "halfway" between two colors. This is basically the goal of calculating a gradient, to sample colors on a line between two colors for colors that are slightly more similar to the target color, with each step being roughly the same amount closer to the target.

Here's a comparison of the gradients created by this PR versus those in master (made using HSV):

Comparison of the two gradient creation algorithms. The gradients on the left were made with OKLab, and the ones on the right are what HMA currently creates.

There is one issue I ran into: this doesn't seem to play nice with changing values in the color picker when multiple colors of a gradient are selected. I'm not sure what the best way to fix that would be. It's possible to spin this coordinate system into something similar to HSV, but doing that makes the browns in the last gradient even more prominent:

image

haven1433 commented 1 year ago

I'll take a closer look at this tomorrow to see what I can figure out, thanks for taking this on!

haven1433 commented 1 year ago

I used this as a basis for this change, which includes this, plus changes to PaletteControl.xaml.cs to get parallel-color-shift working correctly. Thanks for looking into this!