Page 1 of 1

compositing Venn diagrams

Posted: 2007-07-18T13:28:24-07:00
by aschig
I would like to use circles of different colors such that they are solid filled, but as I lay one circle to partially overlap another, the part where they overlap has a third color.

So
Draw circle points 20, 20 20, 30 fill red
Draw circle points 25, 20 25, 30 fill blue

except that the overlapping region is yellow.

Any help greatly appreciated.
No previous images need exist, everything can start from scratch.

Re: compositing Venn diagrams

Posted: 2007-07-26T09:13:50-07:00
by aschig
Hi,

I have made some progress with ImageMagick in making these, but donot know how to convert the composite command (the way I have used it) in to perl's magick.

If I make im1.png and im2.png in this way:
$im1->Draw(primitive=>'circle',points=>'270,220 270,250', fill=>'red');
$im2->Draw(primitive=>'circle',points=>'250,210 250,240', fill=>'blue');

Then I can get to overlap them with the overlapping portion seen in a separate color using
composite and then coloring it the way I want using convert. How do I do that in perl? Can the two be combined? Is there an overall shortcut?

composite im2.png im1.png im1.png out.png
convert out.png -fill yellow \
-draw 'color 266,209 floodfill' color_floodfill.png

Help will be appreciated.

-aschig

Re: compositing Venn diagrams

Posted: 2007-10-03T03:32:08-07:00
by anthony
If you draw the circles on separate canvases, then either 'screen' or 'add' them together, you can generate a 'purple color...

An example of this is with compose 'plus' in IM Examples....
http://www.imagemagick.org/Usage/compose/#plus

The other way is to generate the yellow area separately by compositing the two circles to produce a mask of the area that can then be 'colorized' completely yellow before this is overlaid on the main canvas.

Either method should produce a better anti-aliased result that trying to 'flood fill' the area which rarely produces a acceptable result... See IM Examples, Anti-aliasing for examples of trying to flood fill images with anti-aliased edges.