Hi @jan.cosmigo and guys,

I was trying to setup a multi-shading formula.

My goal with this formula is almost exactly the same as multi-shading mode, but without the additional step of setting up the gradient and hopefully follows shading principles via HSB.

I’ve made this wonky formula for the Left Mouse Button in HSB tab.

**Hue:**

`if ((fgh >= 45 and fgh <= 55), fgh, if(fgh < 45, if((fgh - 10) < 0, ((fgh - 10) + 359), (fgh - 10)), if(fgh > 55, if((fgh + 10) > 359, ((fgh + 10) - 359), (fgh + 10)), fgh)))`

**Sat:**

`if ((fgs >= 0 and fgs <= 100), fgs, if(fgs < 0, if((fgs - 10) < 0, ((fgs - 10) + 100), (fgs - 10)), if(fgs > 100, if((fgs + 10) > 100, ((fgs + 10) - 100), (fgs + 10)), fgs)))`

**Bright:**

`if ((fgb >= 0 and fgb <= 100), fgb, if(fgb < 0, if((fgb - 10) < 0, ((fgb - 10) + 100), (fgb - 10)), if(fgb > 100, if((fgb + 10) > 100, ((fgb + 10) - 100), (fgb + 10)), fgb)))`

*Then reverse the operators in the formula for right mouse button to shade.

10 here is a sample constant i want to keep tweaking when looking for the amount/level of H/S/B jumps.

I suspect that since PM’s color palette is forever in indexed mode, it’s bound for this formula not to work 100% of the time… Okay, more like it works 10% of the time with some palettes. And 0% for high contrast palettes, especially 1bit.

At first glance, you could already tell how messy this looks. So i was hoping i could assign some equations into variables. I found this in the doc:

But it doesn’t seem to do what i thought it would. Which is assigning stuff to a variable. Hence the question, How?

If you guys wanna improve the formula i just posted, please, **feel free and post it here**! I would love to know an optimized version. And disclaimer: I’m pretty sure there is, but i have no idea what the theoretical formula and average constant is for changing hues/sat/bright from one step to the next while in context to a certain feel

This formula was inspired by one of the demos I’ve seen from Pyxeledit where there are already shade and light color options available once you choose a base color.