[reportlab-users] RGBA Colors

Peter peter at maubp.freeserve.co.uk
Thu Nov 26 06:02:29 EST 2009


On Thu, Nov 26, 2009 at 10:45 AM, Andy Robinson <andy at reportlab.com> wrote:

>

> 2009/11/26 Robin Becker <robin at reportlab.com>:

>> My preference for an interaction between the canvas and colour alphas would

>> be something like a set of rules for the colour behaviours

>

> I think we should step back a bit.   First of all, is anyone on this

> list apart from Kevin using opacity?


I'm not using it, but would like to for both PDF, PNG, SVG output
plus perhaps even PS output. I would be using reportlab.graphics
shapes objects and the reportlab.graphics renderPS, renderPDF,
renderSVG, renderPM modules.


> I know we try very hard not to break code, but it seems cleaner and

> more useful to me if RGBColor instances just grow a fourth attribute

> with a default of 1, and we deprecate the opacity methods on the

> canvas.  And then, every time we set a colour, we set the alpha too.

> You could then make a shape or flowable whose colour was 'red with 50%

> opacity'.


That would suit me.


> Every set-colour operation will need a few extra bytes of

> (uncompressed) markup and a tiny bit of processing.  However, we have

> to ask what proportion of real-world documents switch colours hundreds

> of times.


I'm thinking here about output from GenomeDiagram (now part of
Biopython). In some cases the might just be a handful of colors, e.g.
http://biopython.org/DIST/docs/tutorial/images/plasmid_linear_nice.png

However, we produce much more complicated examples which
could be using thousands of colours to visualise data, e.g. see:
http://bioinf.scri.ac.uk/lp/programs.php#genomediagram

Supporting opacity via the an alpha channel (perhaps linked to
the color) might be very useful - for example as a simple way to
draw overlapping genes.


> We would also have to look at renderPM and the bitmap output, as

> ideally any kind of bitmap preview (common on the web) should be

> fairly faithful.   Robin, does renderPM/libart have the capability in

> principle to show transparent output?

>

> We have done some work recently in the print world where there are

> other techniques for achieving transparency or blends, and we did that

> by adding a 'density' parameter to the relevant colour objects.


Sounds good.


> Robin, would this be cleaner internally than supporting 'both ways'?

>

> Kevin, would this fit better with what you want to do?

>

> Everyone, is this a more useful model for transparency?


Which model are you asking about? Having the transparency
as part of the color seems fine as I would want to assign
transparency at the shape level (e.g. boxes, lines, etc).

Peter


More information about the reportlab-users mailing list