From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/17889 Path: main.gmane.org!not-for-mail From: Mojca Miklavec Newsgroups: gmane.comp.tex.context Subject: Re: [metapost] shading in meta[post/play] & PDF Date: Wed, 19 Jan 2005 11:00:08 +0100 Message-ID: <41EE2FA8.4080002@guest.arnes.si> References: <20050115210457.24F53127CC@ronja.ntg.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080901080902000205060201" X-Trace: sea.gmane.org 1106128830 15221 80.91.229.6 (19 Jan 2005 10:00:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Jan 2005 10:00:30 +0000 (UTC) Cc: metapost@tug.org Original-X-From: ntg-context-bounces@ntg.nl Wed Jan 19 11:00:24 2005 Return-path: Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CrCdT-0003D5-00 for ; Wed, 19 Jan 2005 11:00:23 +0100 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C8C3912792; Wed, 19 Jan 2005 11:00:22 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (ronja.vet.uu.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24329-04-3; Wed, 19 Jan 2005 11:00:19 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9965A12777; Wed, 19 Jan 2005 11:00:19 +0100 (CET) Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2AE1B12777 for ; Wed, 19 Jan 2005 11:00:18 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (ronja.vet.uu.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24329-04-2 for ; Wed, 19 Jan 2005 11:00:16 +0100 (CET) Original-Received: from acheron.informatik.uni-muenchen.de (unknown [129.187.214.135]) by ronja.ntg.nl (Postfix) with ESMTP id E2C6E1276C for ; Wed, 19 Jan 2005 11:00:16 +0100 (CET) Original-Received: from internaldeliver.acheron.informatik.uni-muenchen.de (localhost [127.0.0.1]) by acheron.informatik.uni-muenchen.de (Postfix) with ESMTP id C327B435A1; Wed, 19 Jan 2005 11:00:16 +0100 (CET) Original-Received: from [141.84.28.136] (a136.lmu.vpn.lrz-muenchen.de [141.84.28.136]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by acheron.informatik.uni-muenchen.de (Postfix) with ESMTP id B095843592; Wed, 19 Jan 2005 11:00:16 +0100 (CET) User-Agent: Mozilla/4.5-4.75 (Windows; U; Windows NT 5.1; sl-SI; rv:1.4) Gecko/20030624 Netscape/7.1 X-Accept-Language: sl, en, en-us, de Original-To: mailing list for ConTeXt users In-Reply-To: <20050115210457.24F53127CC@ronja.ntg.nl> X-Virus-Scanned: by amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: by amavisd-new at ntg.nl Xref: main.gmane.org gmane.comp.tex.context:17889 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:17889 This is a multi-part message in MIME format. --------------080901080902000205060201 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit The answer to the mail follows, but to reformulate my question slightly: How can I make shading inside metapost(play) to produce exactly what's in the attached picture (smooth shades). Or more generally: how can I "hardcode" some PS/PDF code in .mp, not (yet) supported by metapost(play)? (PDF supports even 3D shapes (already shaded properly) since version 1.5 or 1.6, but I suppose that's another story anyway.) Here's the corresponding PostScript code: %!PS-Adobe-3.0 Resource-ProcSet %%Title: Hsbwheel.ps %%Creator: Henry McGilton, Adobe Systems Incorporated (modified!) %%EndComments 200 dup scale /X3 1.0 3 div def /X6 2.0 3 div def /Y3 1.0 3 div def /Y6 2.0 3 div def /middlecolor [ 1 1 1 ] def /topcolor [ 1 0 0 ] def /rightcolor [ 0.5 0 1 ] def newpath << /ShadingType 6 /ColorSpace /DeviceRGB /DataSource [ 0 0.0 0.0 X3 0.0 X6 0.0 1.0 0.0 1.0 .552 .552 1.0 0.0 1.0 0.0 Y6 0.0 Y3 0.0 0.0 0.0 0.0 0.0 0.0 middlecolor aload pop rightcolor aload pop topcolor aload pop middlecolor aload pop ] >> shfill showpage ************************************************************************ Laurence Finston wrote: > 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 >>example. > > > 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. Well - the main question is how to add the proper (smooth shading) color once I calculate the grid points in one way or another. > 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 > single color. > > 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. Well, PostScript can be used for raster images, but that doesn't bring anything. The examples on Cass' page are actually done using *vector* graphics (colors are really calculated only in grid points, but then the color is interpolated by postscript interpreter): the perfect sphere coloring is thus really limited to "floating point accuracy" and printer capabilities. >>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. No, I wasn't talking about the PNGs. I was talking about the PostScript pictures. http://www.math.ubc.ca/~cass/graphics/manual/code/doughnut.eps has a really *perfect* shading, but its edges are drawn using straight segments instead of drawing them with splines which damages slightly the whole impression of its perfectness. Some additional calculation for spline drawing would help, but I still find it easier to calculate the curves in metapost than in PostScript. Those "straight-line segments" on printers are just as straight as they are on any laser print-out of texts if I'm not wrong - i.e. not worth considering. Thank you, Mojca --------------080901080902000205060201 Content-Type: application/pdf; name="hsbwheel.pdf" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="hsbwheel.pdf" JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURl Y29kZT4+CnN0cmVhbQp4nCtUMNAzVDAAQSidnMulH2SpkF4MpAyB3GIgZahQnJzHZaiQyQVS YWRgACWKUrnSuAK5AAP1DsVlbmRzdHJlYW0KZW5kb2JqCjYgMCBvYmoKNTcKZW5kb2JqCjQg MCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94IFswIDAgMjAwIDIwMF0KL1JvdGF0ZSAwL1Bh cmVudCAzIDAgUgovUmVzb3VyY2VzPDwvUHJvY1NldFsvUERGXQovQ29sb3JTcGFjZSAxMyAw IFIKL0V4dEdTdGF0ZSAxNCAwIFIKL1BhdHRlcm4gMTUgMCBSCi9TaGFkaW5nIDE2IDAgUgo+ PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjM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0lu Zm8gMiAwIFIKPj4Kc3RhcnR4cmVmCjE1NTkKJSVFT0YK --------------080901080902000205060201 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context --------------080901080902000205060201--