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 20:02:14 +0200	[thread overview]
Message-ID: <D475154D-8B65-45A7-BA63-E5DF1A0FADCA@fiee.net> (raw)
In-Reply-To: <nycvar.YAK.7.78.908.2105131313370.845768@nqv-guvaxcnq>

[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]



> Am 13.05.2021 um 19:17 schrieb Aditya Mahajan <adityam@umich.edu>:
> 
> On Thu, 13 May 2021, Henning Hraban Ramm wrote:
> 
>> 
>>> Am 13.05.2021 um 18:36 schrieb Aditya Mahajan <adityam@umich.edu>:
>>> 
>>>> Now I want to draw that path several times.
>>>> 
>>>> If I understand it right, I can’t put that into "sketchdraw" because that leaves the end open for path additions like "withcolor".
>>> 
>>> A slightly different approach is needed. See attached. I also added a bit a error protection in case someone sets sketch_passes to be negative by mistake. 
>> 
>> Thank you so much!
> 
> Here is a different effect ... more of a trembling hand drawing than a sketch. You can play around with sketch_amount to see some variation. 
> 
> In this, rather than using the default randomized path (which randomizes the points of a path), I split the path into 20 segments, and randomize each segment. 

Thank you, that is what I was asking for!

Unfortunately, the deviation of edge points is too big – try my attached test file.

Strangely, if I include the MP code in a ConTeXt document, the transparency doesn’t work (it multiplies, but at 100%); I must add "withtransparency ("multiply", 0.2)" to my draw command. I’ll try to come up with a MWE. (Transparency of an image also doesn’t work in that document.)

My test file also includes the noise overlay after Jairo’s suggestions. Maybe you want to implement that, too?
At the moment it still doesn’t respect the pen size, and the number of patterns per path is fixed.

Hraban



[-- Attachment #2: sketchtest.mp --]
[-- Type: application/octet-stream, Size: 2227 bytes --]

input mp-sketch;

beginfig(1)
  color darkblue ; darkblue := (40/255,67/255,117/255) ;
  color beige ; beige := (248/255,245/255,236/255) ;
  %pickup pensquare xyscaled 4bp rotated 30 ;

  % bleed box, paper shading
  fill (-3mm,-3mm)--(-3mm,300mm)--(213mm,300mm)--(213mm,-3mm)--cycle withcolor beige;

  pen pillpen ; pillpen := makepen ((-1.5bp,-0.5bp)--(1.5bp,-0.5bp)..(1.5bp,0.5bp)--(-1.5bp,0.5bp)..cycle) ;
  pickup pillpen xyscaled 3bp ;

  sketchypaths;
  sketch_amount := 5bp;
  sketch_passes := 5;
  sketch_segments := 5;

  path one ; one := (-3mm,249mm) -- (185mm,249mm) -- (185mm,300mm) ; % links-oben
  path two ; two := (25.5mm,-3mm) -- (25.5mm,130mm) -- (213mm,130mm) ; % unten-rechts

  draw one withcolor darkblue;
  draw two withcolor darkblue;

  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 darkblue withtransparency ("normal", (uniformdeviate 0.33));
  		endfor
  	endfor
  );

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

  noisify(one);
  noisify(two);

  naturalizepaths; % Restore the value of draw and fill

  % draw crop box (paper size)
  pickup pencircle xyscaled 0.5bp;
  draw (0,0)--(0,297mm)--(210mm,297mm)--(210mm,0)--cycle withcolor magenta;

  % begingroup;
  % save Rnd; let Rnd = uniformdeviate;
  %
  % numeric u; u := 3mm;
  % picture PlumaToo;
  % PlumaToo := image(
  % 	for i = 1 upto pmax:
  % 		for j = 1 upto pmax:
  %       fill fullcircle shifted (i - (pmax/2), j - (pmax/2)); %try fulltriangle or another shape
  % 		endfor
  % 	endfor
  % );
  %
  % for i = 0 step 1/20 until length one:
  % 	draw image(
  % 	for x within PlumaToo:
  % 		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
  %     withtransparency ("normal", Rnd 1);
  % 	endfor
  % 	) rotated (90 + angle direction i of one)
  % 	shifted point i of one;
  % endfor
  % endgroup;


endfig

[-- Attachment #3: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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 18:02 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 [this message]
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

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=D475154D-8B65-45A7-BA63-E5DF1A0FADCA@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).