From p.murrell at auckland.ac.nz  Sun Feb 10 21:37:41 2008
From: p.murrell at auckland.ac.nz (Paul Murrell)
Date: Mon, 11 Feb 2008 09:37:41 +1300
Subject: [Rd] help with R rendering engine
In-Reply-To: <509e0620802090515l5e6618act40b4a0befc2fc547@mail.gmail.com>
References: <47AB8AF9.5000202@gmail.com>
	<509e0620802090515l5e6618act40b4a0befc2fc547@mail.gmail.com>
Message-ID: <47AF6095.4010504@stat.auckland.ac.nz>

Hi


Michael Lawrence wrote:
> On Feb 7, 2008 4:49 PM, Mark W Kimpel <mwkimpel at gmail.com> wrote:
> 
>> I'm doing some work on a potential patch to the Bioconductor package
>> Rgraphviz and have some questions on code that is contained in engine.c.
>> In particular, I am developing some custom shapes using polygon and need
>> to make sure that, with rendering, the line connecting the centers of
>> two polygons stops at the border of each polygon. The polygons can be
>> transparent, so the option of just rendering the lines first won't work.
>>
>> Is there some help for me with an R internal or perhaps a higher level
>> function?
>>
> 
> I have to admit I am not that familiar with R graphics, but a very common
> way to achieve this in general is to use clipping. That is, you would set
> the regions covered by your node polygons as the "clip" and then draw your
> edges. Anything drawn onto the clip region is discarded. You would then
> reset the clip and continue drawing.
> 
> I'm pretty sure that base R does not support the complex clip regions you
> would require. However, it would be possible to do this in R by rendering to


That's right.  R's graphics engine only copes with rectangular clipping
regions.

OTOH, the 'grid' package does have a facility to determine locations on
the edges of objects (see grobX() abnd grobY()).  This is not
fully-featured, but for convex polygons it might give you what you want.
There's an example or two in
http://www.stat.auckland.ac.nz/~paul/Talks/rgraphs.pdf

Paul


> pixmaps in memory and then compositing the pixmaps. The first part is
> supported by the cairoDevice package and the latter part by RGtk2 (in
> particular its binding to GDK). I'm sure you'd rather not introduce such a
> dependency on Rgraphviz, but it's an option. I think the graphviz developers
> are moving towards GTK+/Cairo in terms of plugins and other work.
> 
> I checked libgd (already a dependency of graphviz) but found that it only
> supports a single rectangle for clipping.
> 
> Anyway, I hope this helps a little and good luck,
> Michael
> 
> 
>> Thanks,
>> Mark
>> --
>>
>> Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
>> Indiana University School of Medicine
>>
>> 15032 Hunter Court, Westfield, IN  46074
>>
>> (317) 490-5129 Work, & Mobile & VoiceMail
>> (317) 204-4202 Home (no voice mail please)
>>
>> mwkimpel<at>gmail<dot>com
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



[Rd] help with R rendering engine
Paul Murrell