Tgif Home
----
About Tgif
Current Release & Download
FAQ
Copyright Info
A Screendump of Tgif
Release History
Tools That Tgif Uses
Tools That Work with Tgif
Author of Tgif
Miscellaneous Info
----
 
Return to Tgif's Home Page
William Chia-Wei Cheng
(bill.cheng@acm.org)
 

Tgif FAQ - Intersections

 
I want to paint different regions in a Venn Diagram with different colors and produce a GIF file. How can I do it in tgif?
In general, it's difficult to generate objects based on intersections of arbitrary geometrical objects. (Of course, getting the intersections of rectangles are easy.) So, if you want a vector-based object that represents an intersection of arbitrary objects, tgif won't be able to do that in general. However, for regularly shaped objects, such as circles, there may be ways to do it.

If all you want is a GIF file, no problem, please read on.

The best way to explain this is probably with an example. So, here are the step to color different regions in a 3-circle Venn Diagram. The final GIF image is show here first.

image of the final Venn Diagram

  1. First of all, you need to decide if you want transparent background in the final image. If you do, you need to select a color which you won't use in your figure. For example, you can pick "#ff9900" as the color to be made transparent. Then you can set the following X default (if you have giftrans):
        Tgif.XpmToGif: xpmtoppm %s | ppmtogif | giftrans -t "#ff9900"
    Please see Export GIF and Tgif.XpmToGif for more details.

  2. Now, create 3 interesecting circles having the NONE fill pattern and black color. Save the file as "foo.obj".

  3. If the Print/ExportInColor menu item of the Layout Menu is not checked, please check it.

  4. Set print/export format to X11 pixmap by selecting the X11 bitmap/pixmap format from the Print/ExportFormat Submenu of the File Menu.

  5. Export the current file to an X11 pixmap file by selecting Print() from the File Menu. This should create a file named "foo.xpm".

  6. Import "foo.xpm" by selecting ImportXPixmap() from the Import Submenu of the File Menu.

  7. Pin the ImageProc Menu by dragging on the ImageProc Submenu item of the Edit Menu to the left or right far enough to the ImageProc Menu tears off.

  8. Select the imported pixmap object, select a desired color to use for filling a region, and select FloodFill() from the pinned ImageProc Menu. Click all the regions you want to fill with the current color with the left mouse button. When you can done, click the middle button. Repeat this step until you are done.

  9. Finally, set print/export format to GIF by selecting the GIF format from the Print/ExportFormat Submenu of the File Menu. Select the pixmap object and select PrintSelectedObjs() from the File Menu. Please ignore the "Cannot find any 'href=' attributes... Imagemap not generated..." message.