copyDecomposedLayer()

Are there any news on this method including caps and corner components? There are so many plugins that rely on that, but render themselves totally useless in a cap/corner-component workflow. @GeorgSeifert We discussed this already via e-mail, you thought about implementing it.

I got it to work in Show Interpolations at one point but recently saw it stopped working again.

I know, ever since I saw something about it in the change Log of a recent cutting edge, I vainly seeked for it to work. :slight_smile:

That should be fixed in the latest version (916).

Unfortunately not really. Still get awkward results. These two images show how it’s rendered in »Kernkraft« and »Show Interpolations«:

I think I will deprecate copyDecomposedLayer() soon. Please use layer.drawBezierPath.

The Show Interpolation reporter does not use the copyDecomposedLayer. I send a pull request to fix it: https://github.com/mekkablue/ShowInterpolations/pull/5

Thanks @GeorgSeifert

I am going to implement this method. Hope this will work also in the instances where I make visual differentiations between paths and components …

if you need to differentiate, you can’t use copyDecomposedLayer but have to collect the paths from all components.

Is it possible somehow to add a removeOverlap() to the layer.drawBezierPath ?

Why? Copy the layer, decompose it, remove overlaps, then get its bezierPath.

AFAIK there is no decompose() method for a layer. That’s why :slight_smile:

The whole thing ist still about including Caps and Corner Components in all these decomposed stuff. Which works well so far, except for the thing from my last Q.

Also, decomposing manually doesn’t include them as well. Probably this is intentionally, but I kind of would expect it (even though I am aware that corners and caps are handled rather like hints than like components). Though from the POV of the user, they are treated like components.

Why do you need to overlap removed?

There are many:

GSLayer.decomposeComponents()
GSLayer.copyDecomposedLayer()
GSLayer.decomposeCorners()
GSLayer.decomposeComponent_(component)

As mentioned above by Georg already, he might deprecate this particular one.

Well, anyway, I see, I gotta decompose all components, then decompose all caps, then decompose all corners, then remove overlaps and I’m ready to go. Will give it a try, hope it works.

I want to draw overlapping shapes with a very thin outline, and the overlaps are in the way in that particular case. I have this option in a plugin since longer. But just during the introduction of caps & corners into my workflow, I realize their current constrains.

If you need to fix the rendering in the preview, what problem do you have with layer.drawBezierPath()? It includes corners and all.

If you need to draw the components individually, do something like this:

NSColor.greenColor().set()
path = layer.bezierPath
if path != None:
	path.fill()
NSColor.blueColor().colorWithAlphaComponent_(0.6).set()
for component in layer.components:
	path = component.bezierPath
	if path != None:
		path.fill()

I see if I can find a fast solution for the stroke problem.

Thanks, Georg. Drawing components individually is not the problem though :slight_smile:

I tried a chain like this:

newLayer = layer.copy() 
newLayer.decomposeCorners() # gives strange results
newLayer.removeOverlap()
newLayer.drawBezierPath # without parentesis
newLayer.stroke()

Note: In general, this is not a really important issue. Rather a nice to have. Basically I am just trying to figure out, how to include the caps and corners into the drawing optimally. Please don’t let yourself interrupt from working on other things. :slight_smile:

If you do this it should look like this:

newLayer = layer.copy() 
newLayer.removeOverlap()
newLayer.drawBezierPath.stroke() # without parenthesis

The remove Overlap should give you the corners already. But that is a very heavy operation. You need to cache the bezierPath if you need to draw often.

For me, remove Overlap does not include the corners (or caps):

Good to know about the caching!

BTW: I cannot apply .drawBezierPath.stroke() in one go, because I also move it around with an NSAffineTransform. But that’s no problem at all.

can you add a newLayer.parent = layer.parent before the removeOverlap?