Skip to content

Draft: adding clipping layer feature to krita

Igor Wect requested to merge xenys/krita:clipping-layer into master

Just in case someone doesn't know - clipping is a function in Photoshop (and other programs) very similar to inherit alpha in krita. The difference is it take alpha from only one layer while in krita it takes combined alpha from all layers in group.

Which one better is question of personal preference but for the sake of compatibility it’ll be great to have clipping in krita. It’ll make life easier for those who have to work with psd files but doesn’t want to deal with PS.

So, I tried to implement that and succeeded at least partially:

  • the result looks correct
  • it looks identical in PS and krita
  • it support different layer blending modes, opacity visibility, masks and selections
  • it can clip to single layer or group
  • merging down layer is working (but merging multiple doesn’t yet)
  • saving and loading works in psd, works with problem in kra

There is also video demo (and visual glitch is fixed by now).

At the moment I just changed AlphaChannel functions for convenience, if everything is ok I’ll make new functions for clipping and create ui. Actual clipping happens in kis_layer_projection_plane.

Need to discuss:

  • did I ever do in correct way, is here some problematic situations for this implementation?
  • obviously, UI

To do:

  • fix saving in kra
  • fix multiply layer merge
  • fix glitches with enabling\disabling clipping
  • make it work with pass through groups
  • fix layer styles
  • make new functions for clipping
  • connect clipping functions with ui

About ui, my suggestion is simple – just add one more little icon next to layer, something like this:


That way it’ll be easy to switch between different modes as well as disable or enable any. I also think if one mode is enabled the other should be disabled automatically (having both ON doesn’t make sense anyway). Either alpha inherit or clipping or nothing.

Honestly I didn’t test current version much but I gave it to a fried and she says it works pretty good and stable (unlike first versions :D).

Edited by Igor Wect

Merge request reports