From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from cgl.ntg.nl (Cgl.ntg.nl [5.39.185.202]) by inbox.vuxu.org (Postfix) with ESMTP id 1520823E76 for ; Sun, 12 May 2024 19:36:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 6A32F484BD2 for ; Sun, 12 May 2024 19:36:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Authentication-Results: cgl.ntg.nl (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=gmail.com Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jr-3_1hBlhot for ; Sun, 12 May 2024 19:36:48 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 6768D484B59 for ; Sun, 12 May 2024 19:36:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id A8DCB484B19 for ; Sun, 12 May 2024 19:36:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08nsARxeZW_3 for ; Sun, 12 May 2024 19:36:27 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.51; helo=mail-lf1-f51.google.com; envelope-from=mickep@gmail.com; receiver= Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id 5076A484B13 for ; Sun, 12 May 2024 19:36:27 +0200 (CEST) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51fdc9af005so5718483e87.3 for ; Sun, 12 May 2024 10:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715535386; x=1716140186; darn=ntg.nl; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=x8VX14u+fOHvTqvK9O6q0BoVNGjAfUALcQuseQX/cA0=; b=OIuFJaPkxF0tLpObrhuAvuzsyR3TfQ0uJh11BeIpfOpHtVm/0rDY7zbV33AiMn9Cmx k03kMoPOrL+nQOKrAM5LW7KLOlH2ZorY5Sw/oQyC7sje+tVOUHF9HDVNQphcJpJx3nHa /Y3ubMOgDR0hES+5x3B3Q6tHUG52Yu7xvotZABMvnIOtYN1XQRQFY8XMpC1WETxZN2gd 557XnDWmgiVsU4VoW//W/SCzlNmVUnvwyjjG8f4g3+cci1YktRTQ/3WQoTl5W85x5HAx bXgzXsBJ8yoPEzlOlmsWNrLYhMUa7ytikXnlaQNr1S1YtmJU2y6PRtnQACkvirmv6rX1 nO1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715535386; x=1716140186; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=x8VX14u+fOHvTqvK9O6q0BoVNGjAfUALcQuseQX/cA0=; b=vcV1Ri6AE1IdfOWTLutqhUSJ5neYaek7Yjzkke06Lt421XoJi6nzdkCXHasYPCvS/L npTNYtf5uTIliXkOt/FD2MCUVWz9+STN27KpRRgn7g6XRiIno4r8htqXHnVDrWTZkaqN SLljq6+hpwChaSvu4IqybeffdfCsTkL/ddda+6blZuu///Y+ZIbg1QWkOpz/GTlwSi81 X6VXhsKST4L48LqfxOpVRPkkVfplWeSWqDgr5XzxKqOe+CND9v1MuTbhhoN+mIybkc38 Dv7PjI++MgIm/D4Rsbh8xG0u8v2KuDbJdXlPT6NRCO5UP3DD2sJoXFdDnTYDWjpZiqWh lR7Q== X-Gm-Message-State: AOJu0Yy0VnLXnl5ALbivTC2oWWP97Tf/hUXJgOMXi9qbAHZhXn64gGhh 8Dv9+MydOMgYU8xyle+mKOWKZG1Sv1wbo4CIgFOTuQZW4lt/Ky99R1QGytTybeCkddDOt3TjRBa jKHmkeeVFS7J0KaM5Xnxm4IcXYDDesA== X-Google-Smtp-Source: AGHT+IGCFQGkP9WhIJvv9C6+YNh36pqPEDlek/6eapn06jXCwq4o1c48O1sSDt1XZhkholRswS8zNaY4bchoR0wUwHY= X-Received: by 2002:a05:6512:158e:b0:522:2be6:6fcd with SMTP id 2adb3069b0e04-5222be6704cmr5976757e87.25.1715535386088; Sun, 12 May 2024 10:36:26 -0700 (PDT) MIME-Version: 1.0 References: <47b2c0fa-2a12-4571-bc08-15e3057ffbfb@xs4all.nl> <65ba8ca0-b133-4b33-a087-49e10c30acf3@xs4all.nl> In-Reply-To: From: Mikael Sundqvist Date: Sun, 12 May 2024 19:36:13 +0200 Message-ID: To: mailing list for ConTeXt users Message-ID-Hash: AJRYLJGEZBJO4B4N43452YR6I3XCQR6X X-Message-ID-Hash: AJRYLJGEZBJO4B4N43452YR6I3XCQR6X X-MailFrom: mickep@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: Metapost limitation ? List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: multipart/mixed; boundary="===============5106898345059752431==" --===============5106898345059752431== Content-Type: multipart/alternative; boundary="000000000000499bbb06184535b6" --000000000000499bbb06184535b6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Sun, May 12, 2024 at 6:24=E2=80=AFPM Fabrice Couvreur < fabrice1.couvreur@gmail.com> wrote: > > With Okular, it works ! Very good. You can still try the thing below: \startluacode local exp =3D math.exp local N =3D 1000 local xstep =3D 1.6/N local ystep =3D 1.8/N local xmin =3D 0.3 local ymin =3D 0.4 local function f(x,y) local x =3D xstep*x - xmin local y =3D ystep*y - ymin local z =3D x + exp(-60*x) - y if z > 0 then return '1' else return '0' end end potrace.setbitmap("mybitmap", potrace.contourplot(N,N,f)) \stopluacode \startMPpage[offset=3D1dk] path p ; p :=3D lmt_potraced [ stringname =3D "mybitmap", value =3D "1", tolerance =3D 0.1, threshold =3D 0.2, optimize =3D true, ] ; p :=3D p xsized 10cm ; draw p withpen pencircle scaled 5 withcolor "darkblue" ; drawpoints p withcolor "orange" ; drawpointlabels p ; p :=3D subpath(6,19) of p ; draw p withpen pencircle scaled 3 withcolor "yellow" ; \stopMPpage Another thing, Hans added nocycle, so you can write your loop if you want to use it as something like def compute_curve(suffix f)(expr xmin, xmax, xinc) =3D for x=3Dxmin step xinc until xmax: (x,f(x)) .. endfor nocycle ; enddef; Then you do not need to think about the first and/or last point separately. --000000000000499bbb06184535b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Sun, May 12, 2024 at 6:24=E2=80=AFPM Fabrice Couvreur <fabri= ce1.couvreur@gmail.com> wrote:
>
> With Okular, it works !

Very good. You can still try the thing below:

\startluacode
=C2=A0 local exp =3D math.exp
=C2=A0 local N=C2=A0 =C2=A0=3D 1000
=C2=A0 local xstep=C2=A0 =3D 1.6/N
=C2=A0 local ystep=C2=A0 =3D 1.8/N
=C2=A0 local xmin=C2=A0 =C2=A0=3D 0.3
=C2=A0 local ymin=C2=A0 =C2=A0=3D 0.4

=C2=A0 local function f(x,y)
=C2=A0 =C2=A0 local x =3D xstep*x - xmin
=C2=A0 =C2=A0 local y =3D ystep*y - ymin
=C2=A0 =C2=A0 local z =3D x + exp(-60*x) - y
=C2=A0 =C2=A0 if z > 0 then
=C2=A0 =C2=A0 =C2=A0 return '1'
=C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 return '0'
=C2=A0 =C2=A0 end
=C2=A0 end

=C2=A0 potrace.setbitmap("mybitmap", potrace.contourplot(N,N,f))<= br> \stopluacode

\startMPpage[offset=3D1dk]
=C2=A0 path p ; p :=3D lmt_potraced [
=C2=A0 =C2=A0 stringname =3D "mybitmap",
=C2=A0 =C2=A0 value=C2=A0 =C2=A0 =C2=A0 =3D "1",
=C2=A0 =C2=A0 tolerance=C2=A0 =3D 0.1,
=C2=A0 =C2=A0 threshold=C2=A0 =3D 0.2,
=C2=A0 =C2=A0 optimize=C2=A0 =C2=A0=3D true,
=C2=A0 ] ;
=C2=A0 p :=3D p xsized 10cm ;
=C2=A0 draw p withpen pencircle scaled 5 withcolor "darkblue" ; =C2=A0 drawpoints p withcolor "orange" ;
=C2=A0 drawpointlabels p ;
=C2=A0 p :=3D subpath(6,19) of p ;
=C2=A0 draw p withpen pencircle scaled 3 withcolor "yellow" ;
\stopMPpage

Another thing, Hans added nocycle, so you can write your loop if you want t= o use it as something like

=C2=A0 =C2=A0 =C2=A0 def compute_curve(suffix f)(expr xmin, xmax, xinc) =3D=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for x=3Dxmin step xinc until xmax:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(x,f(x)) ..
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 endfor nocycle ;
=C2=A0 =C2=A0 =C2=A0 enddef;

Then you do not need to think about the first and/or last point separately.=
--000000000000499bbb06184535b6-- --===============5106898345059752431== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________ --===============5106898345059752431==--