Layer transparency revisited

Today i have something for the ones who are waiting impatiently for the new layer transparency features, the first screenshots of them ever.

For those who want to have this now on their own systems let me tell that this is highly experimental. First you need to check out the latest cairo version with git and have to patch the file cairo-features.h that it reports a cairo version 1.1.8. Second you need the very latest Scribus-1.3.4cvs sources.

But the results are very promising now, i only have to solve some minor on screen mispaintings. Working on this was also very good in another area of Scribus: the PDF-Export. I was able to fix the longstanding issue that RGB PDF files with transparency showed up in Acrobat Reader 7 with wrong colours.

And now for the pictures:

blendmode.png

Two layers, the stars are on the top layer, which has the “Difference” mode assigned

And another feature that is utterly wanted by some people:

An Overprint Preview on screen

overprint1.png overprint2.png
The on screen preview The same with the regular postscript preview

In this short article I want to explain why Scribus should switch to a cairo based rendering as soon as possible. There are many reasons for doing this despite some drawbacks. But I hope these drawbacks will soon disappear. Let us first look at the benefits of libart:

  • It’s fast
  • Libart has been around for a long time, well tested and stable
  • Can be found in about every distribution and is cross-platform

And now the drawbacks:

  • it seems that it isn’t maintained actively now
  • Sometimes hard to use/find advanced features as the documentation is weak or non-existant.
  • It is missing some advanced features like blendmodes, clipping paths etc..

Cairo is instead a modern, completely developed from scratch rendering library. It’s still under heavy development and has a very active community. Furthermore, the developers are very cooperative in terms of suggestions and feature requests. For Scribus, it would be a very good thing to switch completely to cairo. With the current 1.1.6 version of cairo there is no more excuse not to use it as cairo is now available on all major operating systems. It would greatly ease coding, no more #ifdef HAVE_CAIRO in the code. Second, the code would be much more readable, as the cairo library has a very clean API, which is very close to the Postscript syntax.Instead of boring you with more rants, I’ll show you some differences with a few pictures… a picture says a thousand words….

Rendering Gradients
Both images show a gradient starting with 50% black and ending with 50% black (yes, that’s not really a gradient but should produce an even gray rectangle).
On the left side is the libart one, on the right side the cairo one.
Libart Gradient Cairo Gradient Sample

You see that cairo does exactly what you expect for a gradient like this. libart instead seems to have a bug here, and we do not expect that this will be fixed ever.

Another cool feature that has been added to cairo in their current development snapshot is the push_group and pop_group feature. This does give us the possibility to add real professional transparency features to Scribus. In particular it enables us to add “Layer Transparency” and “Group Transparency”. And if the cairo developers would add more blendmodes we can get very close to the features other proprietary page layout applications.

Normal Transparency Layer transparency
Normal transparency,
2 Objects with 50%
Same objects on a layer
with 50% transparency

This layer transparency feature can also be used to implement an “Overprint preview” mode, i already have the needed maths for this special blendmode. BTW: The current CVS version of Scribus contains already a basic preview mode when build with cairo support.

Final Thoughts

I can’t wait to get hands on the final 1.2 version of cairo. When this release is out we should definitely switch…no more libart woes.

Franz