From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/71895 Path: news.gmane.org!not-for-mail From: "Meer, H. van der" Newsgroups: gmane.comp.tex.context Subject: Re: metapost question Date: Fri, 21 Oct 2011 18:13:19 +0000 Message-ID: <704B0096-D58F-4B75-9229-CDE3F738D3ED@uva.nl> References: <0E2E620E-1148-41AD-9966-54A594FCCE94@xs4all.nl> <4EA18C11.1040502@gmx.net> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1319220818 23387 80.91.229.12 (21 Oct 2011 18:13:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 21 Oct 2011 18:13:38 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Oct 21 20:13:34 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RHJay-0008Uz-G9 for gctc-ntg-context-518@m.gmane.org; Fri, 21 Oct 2011 20:13:28 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E7650CB085; Fri, 21 Oct 2011 20:13:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id a8XgbX7DwYdM; Fri, 21 Oct 2011 20:13:25 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 41DADCB082; Fri, 21 Oct 2011 20:13:25 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 9CB43CB082 for ; Fri, 21 Oct 2011 20:13:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0olBs+e26GzJ for ; Fri, 21 Oct 2011 20:13:22 +0200 (CEST) Original-Received: from filter4-nij.mf.surf.net (filter4-nij.mf.surf.net [195.169.124.155]) by balder.ntg.nl (Postfix) with ESMTP id B8C05CB07F for ; Fri, 21 Oct 2011 20:13:22 +0200 (CEST) Original-Received: from jansen.uva.nl (jansen.uva.nl [146.50.108.229]) by filter4-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p9LIDLco021491 for ; Fri, 21 Oct 2011 20:13:22 +0200 Original-Received: from vanthoff.uva.nl (146.50.108.242) by jansen.uva.nl (146.50.108.229) with Microsoft SMTP Server (TLS) id 14.1.289.1; Fri, 21 Oct 2011 20:13:21 +0200 Original-Received: from ketelaar.uva.nl ([fe80::cc61:4c73:c438:df97]) by vanthoff.uva.nl ([::1]) with mapi id 14.01.0289.001; Fri, 21 Oct 2011 20:13:20 +0200 Thread-Topic: [NTG-context] metapost question Thread-Index: AQHMj/JPwyFporOz80afp1/C9724qJWGxoSAgAAySIA= In-Reply-To: <4EA18C11.1040502@gmx.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [82.95.102.36] Content-ID: X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=146.50.108.229; country=NL; region=07; city=Amsterdam; latitude=52.3500; longitude=4.9167; http://maps.google.com/maps?q=52.3500,4.9167&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 04FLudlgn - ff979148ee8e - 20111021 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.155 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 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 Xref: news.gmane.org gmane.comp.tex.context:71895 Archived-At: Peter, Thanks for trying to help. Because I solved the problem in another way you might be interested or even benefit from it. The underlying problem was drawing a border around a picture of given dimensions. The border being either colored or left uncolored. The border color should come from a withcolor modifier, with the uncolored case done simply by leaving this out, for example: borderinsideframe(u,v,2g); and borderinsideframe(u,v,2g) withcolor red; It turns out this can be done with an unfill. I learned that a bare unfill erases, but add a withcolor modifier and the effect is a coloring. Thus the trick is: def bordercolorframe (expr w, h, off, clr) text modifier = unfill (-off,-off)--(w+off,-off)--(w+off,h+off)--(-off,h+off)--cycle modifier; fill (0,0)--(w,0)--(w,h)--(0,h)--cycle withcolor clr enddef; The omission of a semicolon after the last statement of the def allows one to add in a withcolor somecolor without triggering an error. Hope this will be of use to someone. Hans van der Meer On 21 okt. 2011, at 17:13, Peter Rolf wrote: > Am 21.10.2011 15:05, schrieb Hans van der Meer: >> I cannot find the answer to the following question in Knuth's Metafont book. >> The following definition with a trailing text argument: >> >> def mydef (expr a, b, c) text modifier = >> if : > > Have you already tried > > if modifier = "" : > >> else: >> fi >> enddef; >> >> How can I do the switch on an empty or nonempty modifier argument? It is not a string because calling its length fails with an error. >> I must do the switch, because "fill modifier" with an empty "modifier" gives horrible results. >> >> Usage would be calls like: >> mydef(1,2,3) withcolor green; % with modifier text >> mydef(1,2,3); % without modifier text >> >> Thanks in advance. >> Hans van der Meer ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________