[metapost] shading in meta[post/play] & PDF
lfinsto1 at gwdg.de
Sat Jan 15 22:04:56 CET 2005
Mojca Miklavec wrote:
> There's a wonderful tutorial on drawing 3D graphics in PostScript on
> http://www.math.ubc.ca/~cass/graphics/manual/, specifically
> http://www.math.ubc.ca/~cass/graphics/manual/code/doughnut.eps as an
Thanks for the reference, it looks very interesting.
> In metapost, "perfect" spheres can be drawn, like on
> http://www.gnu.org/software/3dldf/cdsmpls.html. But how can I add > colour?
The spheres in that example are really just circles. The "globe font" was
done using Metafont, which doesn't support color at all. The sphere graphic
at the beginning of that file was done using MetaPost, so the circles could be
drawn in color, but I know this isn't what you mean.
The glyphs from the globe font (which I plan to improve) could be colored,
e.g., by using the macros defined in the `colordvi.tex' file supplied with
`dvips'. Of course, a given glyph could only be printed or displayed in a
GNU 3DLDF does not yet possess a `sphere' type, but I plan to add one in the
not-too-distant future. I also plan to add shading, but that is in the more
distant future. The shading methods I'm (vaguely) familiar with operate on
raster data and I haven't quite decided how to handle rasterization. I'm
leaning toward using the PNG format rather than PostScript for this. I
believe PostScript can be used for both vector and raster data, but my memory
of the details is hazy.
> The spheres drawn directly in PostScript as in the examples above still
> have straight lines (well, I agree that with some mathematics it would
> be possible to draw them with proper splines as well).
If you mean my spheres, that's an artefact of the PNG graphics. The
PostScript versions look nicer. I believe that on commonly available devices,
curves are ultimately drawn as short straight-line segments, though. In the
code in that file, the circles have 64 points, and I thought the results were
good enough. Raising it to some value x such that x % 4 == 0 and x > 64 might
improve them, I haven't tried it. 32 wasn't enough.
More information about the metapost