From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/28876 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: Clipping again Date: Mon, 26 Jun 2006 17:01:08 +0200 Message-ID: <449FF6B4.7040208@wxs.nl> References: <89CFFCDF-F1CE-4005-81D0-D30A633328FE@cox.net> <6faad9f00606260239w79f1b972x874fa268cc984a74@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1151334241 12118 80.91.229.2 (26 Jun 2006 15:04:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 26 Jun 2006 15:04:01 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Mon Jun 26 17:03:56 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fusca-0006QL-5a for gctc-ntg-context-518@m.gmane.org; Mon, 26 Jun 2006 17:03:28 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E78A112874; Mon, 26 Jun 2006 17:03:27 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30194-01; Mon, 26 Jun 2006 17:03:27 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 7C0F812862; Mon, 26 Jun 2006 17:01:22 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 6C67712862 for ; Mon, 26 Jun 2006 17:01:20 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 27284-06-5 for ; Mon, 26 Jun 2006 17:01:17 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with SMTP id 7A320127F0 for ; Mon, 26 Jun 2006 17:01:17 +0200 (CEST) Original-Received: from [10.100.1.102] (unverified [10.100.1.102]) by controller-1 (SurgeMail 3.5b3) with ESMTP id 23699 for ; Mon, 26 Jun 2006 19:01:16 +0400 User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) Original-To: mailing list for ConTeXt users In-Reply-To: <6faad9f00606260239w79f1b972x874fa268cc984a74@mail.gmail.com> X-Server: High Performance Mail Server - http://surgemail.com r=-274017400 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 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: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:28876 Archived-At: Mojca Miklavec wrote: > On 6/25/06, David Arnold wrote: >> Hi, >> >> I confess I got some earlier advice on this issue, but I've never >> been able to apply it to find a resolution. In the buffer that >> follows, I define a clipping box: >> >> /.../ >> >> Unfortunately, even though this works, mathematicians really want >> arrows at each end of the graph. Easy enough to do with drawdblarrow >> P withcolor blue, but the arrows then get clipped. What I really need >> is to adapt the code below so that my function is clipped to the >> boundary box, but then redrawn with arrows at each end of it. If >> anyone can adjust my code to do that, it would be much appreciated, >> and it would break down a barrier I've faced for years with metapost >> coding. >> >> Note that I've tried some stuff with cutbefore and cutafter with some >> success. But I should remark that the code below is generated by a >> perl script and some special coding we've set up to generate these >> graphics on the fly for student quizzes. This is not a situation >> where I can tweak an individual plot or two. Rather, our script might >> generate 100 sets of the code below, all with different parameters. >> So this magnifies the problem. >> >> Again, any ideas would be greatly appreciated. > > Can you check the attached file? I changed a bit more of the code than > you asked for, but I hope that that's not the problem. Only by using > "cutbefore/cutafter" you would have to consider too much cases of > curve orientation and I avoided the usace of clipping completely. It > has some minor problems when drawing a pole of odd orders: this part > of the code > elseif isInside and (not > fallsInside(mytransform((x,ff(x))),cbox)): > should be fixed a bit for such cases, so please let me know if you > need help for the fix. > > The nice part about metapost is that it's a programming language, so > you should write your code in such a way that you never code the same > number more than once - you should avoid hardcoding the numbers (5 > appears quite often in your code) as often as possible. > > Please let me know if you need some explanation - I didn't comment > much in the source itself. impressive btw, no need for an if in: vardef fallsInside(expr apoint, cbox) = (xpart apoint >= xpart llcorner cbox) and (xpart apoint <= xpart urcorner cbox) and (ypart apoint >= ypart llcorner cbox) and (ypart apoint <= ypart urcorner cbox) enddef; ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------