ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Mikael Sundqvist <mickep@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: randomize direction of arrow in metafun
Date: Sat, 15 May 2021 14:42:24 +0200	[thread overview]
Message-ID: <CAHy-LL_9n-Cxu__4gV9kAefjku=dW58Lk24gqqmhaax++7XaGA@mail.gmail.com> (raw)
In-Reply-To: <d4738abc-d443-918d-3a3b-328056a841ec@uni-bonn.de>

Hi,

you could do something like this:

\startMPpage
for i = 0 upto 10:
 drawarrow if uniformdeviate(1)<0.5: reverse fi ((0,0)--(2cm,0)) yshifted i*cm;
endfor;
\stopMPpage

/Mikael

On Sat, May 15, 2021 at 2:30 PM Thomas A. Schmitz
<thomas.schmitz@uni-bonn.de> wrote:
>
> Hi all,
>
> for a slide template, I want to draw colored arrows in a randomized
> color (from a list of colors). This works (and the code is far too
> clever for me, I must have copied it somewhere):
>
> save mycolor ; color mycolor[] ;
> mycolor[1] := (0.2, 0.3, 0.4) ;
> mycolor[2] := (0.6, 0.6, 0.4) ;
> mycolor[3] := (0.5, 0.8, 0.5) ;
>
> so I can write
>
> drawarrow p withcolor mycolor[round(uniformdeviate(9))] ;
>
> But I also want the direction of the arrow to be random. My first idea
> was to define a variable that would expand either to "reverse" or the
> empty string right after drawarrow, but that's where I'm stuck. Anyone
> has an idea how to achieve this? (It's probably somewhere in the source,
> but I can't find it.) And is the method of defining the random color OK,
> or could this also be improved.
>
> Thanks, and all best
>
> Thomas
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2021-05-15 12:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-15 12:30 Thomas A. Schmitz
2021-05-15 12:42 ` Mikael Sundqvist [this message]
2021-05-15 13:02   ` Thomas A. Schmitz

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='CAHy-LL_9n-Cxu__4gV9kAefjku=dW58Lk24gqqmhaax++7XaGA@mail.gmail.com' \
    --to=mickep@gmail.com \
    --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).