aseprite / aseprite

Animated sprite editor & pixel art tool (Windows, macOS, Linux)
https://www.aseprite.org
28.91k stars 5.83k forks source link

Onion skinning with tinting does not work for all colors #1125

Closed Cerno-b closed 8 years ago

Cerno-b commented 8 years ago

I love the onion skinning function but ran into some trouble recently when I tried the red/blue tinting for black pixels, which does not work (you only get grayscale onion skinning).

So I ran some tests. Top to bottom: white, black, blue, green, red. Left column: Previous frame Right column: Next frame

onion

So some colors seem to have trouble getting the tinting right. Instead of using the original onion skin and tinting it, I would suggest the following:

As an example, I will take a black pixel at 000000FF, which currently does not work at all in tinted onion skin. I will assume that the prev tint is supposed to be red with some alpha: FF000040.

The process is as follows:

  1. Convert the prev cel to grayscale (since our pixel is black, this is still 000000FF)
  2. Calculate the per-channel average of the grayscale from 1. (000000) and your target tint (FF0000). Note I left out the alpha channel. You get (7F0000).
  3. Replace the prev cel's alpha with the target tint alpha, so you get 7F000040.

Let's repeat this for a white pixel FF0000FF:

  1. Convert to grayscale (still white): FF0000FF:
  2. Calculate average of orignal FF0000 and target tint FF0000, so you get FF0000.
  3. Add the target tint alpha for the final result: FF000040

Final example for a medium gray pixel at 7F7F7FFF:

  1. Convert to grayscale (still gray): 7F7F7FFF
  2. Calculate average of 7F7F7F and FF0000 to get BF4040
  3. Add the target tint alpha for the final result: BF404040

Visualization here: onion_new

Since this seems to work for the whole grayscale spectrum and you can convert any color cel into grayscale, this should do the trick. You may want to add some weight factors to give it a little more contrast between white and black but in general it should be able to solve the problem.

Please let me know what you think.

dacap commented 8 years ago

Thanks for the details @Cerno-b, I've implemented this for the next release v1.1.5.3

Cerno-b commented 8 years ago

Wow, you're fast! Looking forward to the next release then :)

dacap commented 8 years ago

@Cerno-b it's already available ^_^ (v1.1.5.4 is the latest version available)

Cerno-b commented 8 years ago

I haven't been at my PC for a while, that's good news!