From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/75909 Path: news.gmane.org!not-for-mail From: Mari Voipio Newsgroups: gmane.comp.tex.context Subject: Re: Metapost/Metafun Q: using variables and "building blocks"? Date: Tue, 1 May 2012 00:40:25 +0300 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1335822034 18772 80.91.229.3 (30 Apr 2012 21:40:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 30 Apr 2012 21:40:34 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Apr 30 23:40:34 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SOyKf-0001KE-Qv for gctc-ntg-context-518@m.gmane.org; Mon, 30 Apr 2012 23:40:33 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D90E5101EE; Mon, 30 Apr 2012 23:40:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7+7bmA1a5YxH; Mon, 30 Apr 2012 23:40:31 +0200 (CEST) Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E177D101E9; Mon, 30 Apr 2012 23:40:30 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6E9FB101E9 for ; Mon, 30 Apr 2012 23:40:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 1C7X-4VzgSBd for ; Mon, 30 Apr 2012 23:40:27 +0200 (CEST) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id 648AC101E8 for ; Mon, 30 Apr 2012 23:40:27 +0200 (CEST) Original-Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q3ULePIg022115 for ; Mon, 30 Apr 2012 23:40:25 +0200 Original-Received: by lbjn8 with SMTP id n8so2489708lbj.14 for ; Mon, 30 Apr 2012 14:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=wLOGlwLZokA9c7DB7Wcf3MIMoZlC4KZ7eS6p7N0Bu4I=; b=Uj1cN874rxQOWRsV6Abc7/UE48ZGmKsfJPrUfiKPbTg3BA+n9BCBZx/1ohz4fqd99W 5qkZmFvgkG3bzB4izuTm1oh57C0VCaGA66XBGInGf7mCMqNRN1JI4rHHPn5KV/cmi6o0 nN3fX23oMxCj/6yL2dGOpAUKZzJ4NJSNGzWBWKDaJCFrvHCpmpl+RpOykVS/5reE+M0r he3WG056O3Xot4h9UX9j+QT8BVWo1IFnzFMIZYb5eQ5gPzJqW9HLdRUlxTiA+fRSDHVb tXYJwMy4oxkH9WpTuZGfbW6jJEU4H+WRXARL04Nv6Mx3rRlT/pdbXOQJyDKrf4ZYxhXA i9Vg== Original-Received: by 10.152.115.74 with SMTP id jm10mr14437257lab.32.1335822025321; Mon, 30 Apr 2012 14:40:25 -0700 (PDT) Original-Received: by 10.152.5.9 with HTTP; Mon, 30 Apr 2012 14:40:25 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: _pk4r9NmrUpNMmoDyQ1PR8egd1k X-Bayes-Prob: 0.1032 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.217.169; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0QH4lEp9R - a48900ec5212 - 20120430 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 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:75909 Archived-At: On Mon, Apr 23, 2012 at 20:34, Mari Voipio wrote: > a) I need to be able to stack four of these on top of each other and > then four mirrored ones next to them OK, I really was being stupid - I had already managed to do a "shift" inside a single 'block', somehow I just didn't see that I could do the same to the blocks: \startMPpage picture ll ; % left-hand loop ll := image ( path p, q, r ; p := fullcircle scaled 4mm ; q := p shifted (0mm,10mm) ; r := center p .. (5mm,5mm) .. center q ; pair pr, qr ; pr := p intersectionpoint r ; qr := q intersectionpoint r ; r := r cutbefore pr cutafter qr ; r := r cutends 0.2mm ; draw r withpen pencircle scaled 0.2mm withcolor black ; % the connecting curve draw p withpen pencircle scaled 0.2mm withcolor black ; fill p withcolor black ; % upper shank draw q withpen pencircle scaled 0.2mm withcolor black ; fill q withcolor black ; % lower shank ); draw ll ; draw ll shifted (0mm,20mm) ; draw ll shifted (0mm,40mm) ; draw ll shifted (0mm,60mm) ; \stopMPpage > Keeping in mind that I > will have to be able to draw a path/arrow on top, so I need to know > where they are. My little brain got an overflow from all this abstract thinking, but then it dawned on me that I could use the millimeter grid recipe in the MetaFun manual (p. 214) to draw a grid behind my pattern drawing. Now placing the arrows should be a walk in the park... > b) The circles p and q can be filled with the same colour or two > different colours, and each of the blocks in a pattern can have > different fill colour > > I assume the answer is "use variables", but how? Gaah, I still cannot figure it out! A real example: one of my own patterns has white up and down on first loop, black up white down on second, white up and down on third and blue up and down on fourth. So I'd need draw ll ; % and fill both circles with white draw ll shifted (0mm,20mm) ; % and fill lower circle with white, shifted/upper circle with black draw ll shifted (0mm,40mm) ; % fill both circles with white draw ll shifted (0mm,60mm) ; % fill both circles with blue What is the shortest way of doing this? I don't mind writing definitions earlier in the file, but I'd rather keep this part as short as possible to be able to see the pattern at one glance. The main problem comes from the bicoloured loops as I can't just apply the same fill on both. And on the whole I'd prefer to make sure I apply the fill only locally per each half-loop and not all over the place... Getting closer, Mari PS. I don't have any photos of the above braid, but here's a typical fingerloop braid that I did and need to document: http://www.lucet.fi/2012/04/sydamellista-hearty/ ___________________________________________________________________________________ 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 ___________________________________________________________________________________