From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/21823 Path: news.gmane.org!not-for-mail From: David Arnold Newsgroups: gmane.comp.tex.context Subject: Clipping a path to a boundary --- Being more specific Date: Sun, 7 Aug 2005 18:17:18 -0700 Message-ID: <296DC314-07AA-11DA-B306-001124338712@northcoast.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1123464114 15616 80.91.229.2 (8 Aug 2005 01:21:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Aug 2005 01:21:54 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Mon Aug 08 03:21:45 2005 Return-path: 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 1E1wKh-0006MW-7Q for gctc-ntg-context-518@m.gmane.org; Mon, 08 Aug 2005 03:21:39 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id D805F1277B; Mon, 8 Aug 2005 03:21:38 +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 03358-03; Mon, 8 Aug 2005 03:21:38 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 4D1B6127EC; Mon, 8 Aug 2005 03:18:03 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 0F5E9127EC for ; Mon, 8 Aug 2005 03:18:02 +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 03220-04 for ; Mon, 8 Aug 2005 03:18:01 +0200 (CEST) Original-Received: from borg.inreach.com (mail.northcoast.com [209.142.2.71]) by ronja.ntg.nl (Postfix) with SMTP id 957BB127E6 for ; Mon, 8 Aug 2005 03:18:00 +0200 (CEST) Original-Received: (qmail 4482 invoked from network); 8 Aug 2005 01:15:06 -0000 Original-Received: from unknown (HELO ?209.209.19.216?) (209.209.19.216) by mail.northcoast.com with SMTP; 8 Aug 2005 01:15:06 -0000 Original-To: Context Mailing List List X-Mailer: Apple Mail (2.619) X-Virus-Scanned: 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-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on smtp.ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:21823 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:21823 Hans et al, Let me try to be more specific. Here is a file which is very typical of the way I draw graphs for my mathematics classes. When you compile, you will see the graph of the absolute value of x-1. That is, it draws the graph of y=|x-1|, but only after clipping it to the cpath. What I would like to do is draw the graph with the drawdblarrow command so that the graph of the absolute value ends in arrowheads. So, I want to clip the graph to the bounding box, save the picture, null the picture, then somehow extract the path into the variable F in its clipped form (not the original path F that extends outside the clip path) so that I can replace the command draw pic with drawdblarrow F. beginfig(0); numeric a, c; a=1; % define function f(x)=|x-a| vardef f(expr x)= abs(x-a) enddef; % draw line with given point and slope path F; F:=(-5,f(-5)); for x=-5 step 1 until 5: F:=F--(x,f(x)); endfor; % initialize scale numeric u; 10u=3in; % the line F:=F scaled 1u; draw F withcolor blue; % clipping path path cpath; cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle; cpath:=cpath scaled 1u; % clip and save current picture picture pic; clip currentpicture to cpath; pic:=currentpicture; currentpicture:=nullpicture; % erase currentpicture currentpicture:=nullpicture; % draw grid for k=-5u step 1u until 5u: draw (-5u,k)--(5u,k) withcolor 0.85white; draw (k,-5u)--(k,5u) withcolor 0.85white; endfor; % draw axes drawarrow (-5u,0)--(5u,0); drawarrow (0,-5u)--(0,5u); % label axes label.rt(btex $x$ etex, (5.2u,0)); label.top(btex $y$ etex, (0,5.2.u)); label.bot(btex $5$ etex, (5u,0)); label.lft(btex $5$ etex, (0,5u)); % redraw line draw pic; endfig; end.