ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mari Voipio <mari.voipio@iki.fi>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Metapost/Metafun Q: using variables and "building blocks"?
Date: Tue, 1 May 2012 00:40:25 +0300	[thread overview]
Message-ID: <CAGbDsP0XzJayWZ6vJY3RQ97eWVbYtCZVsmzeG1z_LXgiBAwFyA@mail.gmail.com> (raw)
In-Reply-To: <CAGbDsP2z94hzC96jP5E48hEe7YtFhH9dz7XF5xALhPygJoBMug@mail.gmail.com>

On Mon, Apr 23, 2012 at 20:34, Mari Voipio <mari.voipio@iki.fi> 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
___________________________________________________________________________________


  parent reply	other threads:[~2012-04-30 21:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 17:34 Mari Voipio
2012-04-23 18:04 ` Hans Hagen
2012-05-06  8:53   ` Mari Voipio
2012-05-06  9:05     ` Mari Voipio
2012-05-06  9:16     ` luigi scarso
2012-05-06  9:56       ` Wolfgang Schuster
2012-05-06 10:17         ` luigi scarso
2012-05-06 11:33         ` Pontus Lurcock
2012-05-06 12:30           ` Hans Hagen
2012-05-06 12:47     ` Hans Hagen
2012-05-06 12:53       ` Martin Schröder
2012-05-06 12:59         ` Hans Hagen
2012-05-06 13:39       ` Mari Voipio
     [not found]         ` <4FA6822A.6070400@wxs.nl>
2012-05-08  5:53           ` Mari Voipio
2012-04-30 21:40 ` Mari Voipio [this message]
2012-05-01 17:09   ` Peter Rolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGbDsP0XzJayWZ6vJY3RQ97eWVbYtCZVsmzeG1z_LXgiBAwFyA@mail.gmail.com \
    --to=mari.voipio@iki.fi \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).