Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Aspect Ratio


On Jan 1, 2009, at 9:34 PM , Nathan Myhrvold wrote:

> Thanks!  I was hoping that this would work for arbitrary graphics -
> including Text[] in various fonts.  I will try it.
>
> My goal here is that I want to use Inset[] to compose various 2D and  
> 3D
> graphics together.
>

You can (in V7, at least) also use Rasterize[.., "RasterSize"],  
although you have to be careful about the various XXXPadding options  
to Graphics.

In[130]:= r1 = Graphics[Rectangle[{0, 0}, {1, 10}]];

In[131]:= r2 = Graphics[Rectangle[{0, 0}, {1, 2}]];

In[132]:= Rasterize[r1, "RasterSize"]

Out[132]= {46, 432}

In[133]:= Rasterize[Show[r1, ImagePadding -> 0, PlotRangePadding ->  
0], "RasterSize"]

Out[133]= {43, 432}

In[134]:= Rasterize[Show[r2, ImagePadding -> 0, PlotRangePadding ->  
0], "RasterSize"]

Out[134]= {216, 432}

This should generally be more robust than most other methods I can  
think of, though a bit slower than some other methods, since it has to  
ask the frontend for information about the rendered result instead of  
using information available to the kernel.  The kernel has no idea  
about things like font metrics and so this is probably a better  
approach if you're interested in (styled) text.

Brett Champion
Wolfram Research


  • Prev by Date: Re: Aspect Ratio
  • Next by Date: Re: Non-deterministic numerical inaccuracies in
  • Previous by thread: Re: Aspect Ratio
  • Next by thread: Re: Re: Aspect Ratio