cloudhead / rx

👾 Modern and minimalist pixel editor
https://discord.gg/xHggPjfsS9
GNU General Public License v3.0
3.07k stars 109 forks source link

Command to add a gradient to palette. #93

Closed MonsieurLanza closed 3 years ago

MonsieurLanza commented 3 years ago

I am somewhat new to Rust, so lots of possible mistakes in here.

Anyway, this PR adds a command to add a gradient to the palette using: p/gradient <color_start> <color _end> <steps> which creates steps colors in the palette starting with color_start ending with color_end.

Question is : it currently adds all color, whether it is already present in palette or not. Should it ? p/add does not, but it adds a single color. I cannot really decide on this one.

It misses test, I just have no time to learn how to test in rust. I noticed that similar function tend to be in session.rs. I put my logic in palette.rs as it is palette manipulation, I find it more legible, but it may not be the right way.