ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henning Hraban Ramm <texml@fiee.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Fuzzy lines
Date: Thu, 13 May 2021 15:23:13 +0200	[thread overview]
Message-ID: <3EA3B826-67A8-4017-AA2C-13C64273097A@fiee.net> (raw)
In-Reply-To: <CAKyqqaY0KhGpvsoP7heqymuA2r+ORFq8tT9+qkb2OzwAQdh_fw@mail.gmail.com>


> Am 12.05.2021 um 23:21 schrieb Jairo A. del Rio <jairoadelrio6@gmail.com>:
>> Unfortunately, that’s the same pattern over and over.
>> The randomization is only applied once.
>> Good for footprints, bad for fuzzy patterns.
>> 
> You only need to move "randomized" at the drawing stage:
> 
> \starttext
> \startMPpage
> numeric u; u := 1mm;
> picture Pluma;
> Pluma := image(
> 	for i = 1 upto 5:
> 		for j = 1 upto 5:
> 			draw (i,j);
> 		endfor
> 	endfor
> );

I made it into:

  picture NoisePattern;
  NoisePattern := image(
    pickup pencircle xyscaled 0.5bp;
    numeric pmax ; pmax := 7 ;
  	for i = 1 upto pmax:
  		for j = 1 upto pmax:
        		draw (i - (pmax/2), j - (pmax/2)) 
			withcolor LineColor 
			withtransparency ("normal", (uniformdeviate 0.33));
  		endfor
  	endfor
  );

Now the noise is randomly transparent and also on (and not over) the path.


> path Camino;
> Camino := origin for i = 1 upto 30: .. (u*i, u*sind (12i mod 360)) endfor;
> for i = 0 step 1/2 until length Camino:
> 	draw Pluma randomized 1 rotated (90 + angle direction i of Camino)
> 		shifted point i of Camino;
> endfor

And that became:

  def noisify(expr p) =
    for i = 0 step 0.01 until length p:
    	draw NoisePattern randomized 1 shifted point i of p ;
    endfor
  enddef;

I still need to account for the length of the path in the loop step.


> But "randomized" will deform paths. Maybe you want something like this?
> 
> \starttext
> \startMPpage[align=]
> begingroup;
> save Rnd; let Rnd = uniformdeviate;
> 
> numeric u; u := 3mm;
> picture Pluma;
> Pluma := image(
> 	for i = 1 upto 5:
> 		for j = 1 upto 5:
> 			fill fullcircle shifted (i,j); %try fulltriangle or another shape
> 		endfor
> 	endfor
> );
> path Camino;
> Camino := origin for i = 1 upto 30: .. u*i*left endfor;
> for i = 0 step 1/2 until length Camino:
> 	draw image(
> 	for x within Pluma:
> 		fill pathpart x %Assuming our image only contains cyclic paths
> 		scaled (1+Rnd 1)
> 		shifted (1/2dir Rnd 360)
> 		withcolor hsvtorgb(6round(Rnd 60),9/10,1); %Colors just because they look cute
> 	endfor
> 	) rotated (90 + angle direction i of Camino)
> 	shifted point i of Camino;
> endfor
> endgroup;
> \stopMPpage
> \stoptext

>> Since I have more or less straight lines but of different length, the "one pattern per 1/n path segment" doesn’t work for me. I could try to construct my paths differently.
> You only need to use fractions, i.e., "for 0 step 1/n until 1: ... endfor" if you work with straight lines defined using only two points.

Yes, I got that. But a fixed number (e.g. step 0.01 like above) doesn’t account for paths of different length.
I guess I’d need an algorithm like for dashed lines to get uniform noise on paths of different length.
(I also looked at dashpattern in the MP manual, but they’re not usable for patterns like this.)

Hraban

___________________________________________________________________________________
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-13 13:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 10:58 Henning Hraban Ramm
2021-05-11 11:30 ` Mikael Sundqvist
2021-05-11 12:33   ` Henning Hraban Ramm
2021-05-11 12:56   ` Jairo A. del Rio
2021-05-11 16:02     ` Aditya Mahajan
2021-05-12 18:07       ` Henning Hraban Ramm
2021-05-13 13:08       ` Henning Hraban Ramm
2021-05-13 16:36         ` Aditya Mahajan
2021-05-13 16:55           ` Henning Hraban Ramm
2021-05-13 17:17             ` Aditya Mahajan
2021-05-13 18:02               ` Henning Hraban Ramm
2021-05-13 18:26                 ` Thomas A. Schmitz
2021-05-13 19:42                   ` Henning Hraban Ramm
2021-05-14 15:08                     ` Thomas A. Schmitz
2021-05-13 22:39                 ` Aditya Mahajan
2021-05-14  9:43                   ` Hans Hagen
2021-05-14 20:33                   ` Henning Hraban Ramm
2021-09-03 16:04                 ` Henning Hraban Ramm via ntg-context
2022-01-21 18:00                   ` Iterating over MP paths (was: Fuzzy lines) Henning Hraban Ramm via ntg-context
2021-05-14 10:05           ` Fuzzy lines Hans Hagen
2021-05-12 17:55     ` Henning Hraban Ramm
     [not found]       ` <CAKyqqaaosis=BjOD_mArY5VM+bzcj-ar4uMtnt8SRJ2WLL9ykw@mail.gmail.com>
2021-05-12 21:21         ` Fwd: " Jairo A. del Rio
2021-05-13 13:23           ` Henning Hraban Ramm [this message]

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=3EA3B826-67A8-4017-AA2C-13C64273097A@fiee.net \
    --to=texml@fiee.net \
    --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).