From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106754 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Re: What was that 'rounding paths' metafun(?) function again? Date: Sun, 5 Apr 2020 13:18:12 +0200 Message-ID: <33DA3493-3A75-4B9F-AE93-0DB31F16CA73@rna.nl> References: <10febb0a-a5b0-d6f1-8111-51a735b6488f@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="===============8215992499387737160==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="125653"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mailing list for ConTeXt users To: Wolfgang Schuster Original-X-From: ntg-context-bounces@ntg.nl Sun Apr 05 13:18:35 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jL3IR-000Wa0-4B for gctc-ntg-context-518@m.gmane-mx.org; Sun, 05 Apr 2020 13:18:35 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 51823183082; Sun, 5 Apr 2020 13:18:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A6e6aysU2E94; Sun, 5 Apr 2020 13:18:15 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5D762183099; Sun, 5 Apr 2020 13:18:15 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 61E4C18308E for ; Sun, 5 Apr 2020 13:18:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7bfEWx68lHqP for ; Sun, 5 Apr 2020 13:18:13 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=213.125.118.53; helo=mail.rna.nl; envelope-from=gerben.wierda@rna.nl; receiver= Original-Received: from mail.rna.nl (mail.rna.nl [213.125.118.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 940B1183082 for ; Sun, 5 Apr 2020 13:18:13 +0200 (CEST) Original-Received: from hermione.rna.nl (hermione.rna.nl [192.168.2.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.rna.nl (Postfix) with ESMTPSA id 3612B3CDD143; Sun, 5 Apr 2020 13:18:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1586085493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rkIQn7anXK9b9lPzah302I6iLa4OpZYEArje4rYAuNc=; b=m7UGXFnbeGnzpUAKZDj3RqyJrsKXU0etLk9GKlg54MBygKb7a2gATOLZMxljZy9k7P8Yay //VDwcjIZv857MO4hojL8T95tu2Bqgx3rv2G4b+JjGOiDFqJyINut2JwvMkv0LLLX8jpZW 5q+Jg6mM9ZJ6tK+mAYaoLmc9tIaj1/L/wTSAAyD1xU4DL3IDpiStsiPXiT+GOEU73E/o+y 5DdQGhKNmH3NSOWQPwEdLpSzq1ort9LGmqX0zm4NygZ1w/VXKbjmts8LTvk/mpiKgV26iQ JDuDyslyb6ddzkwsGh9B0N91KEt1dMevKP+gTvax3UQX4V2Ur68QIdqHv1uLxQ== In-Reply-To: <10febb0a-a5b0-d6f1-8111-51a735b6488f@gmail.com> X-Mailer: Apple Mail (2.3445.104.14) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:106754 Archived-At: --===============8215992499387737160== Content-Type: multipart/alternative; boundary="Apple-Mail=_CD7B8EDF-B8B9-4D78-9F33-9A738E100545" --Apple-Mail=_CD7B8EDF-B8B9-4D78-9F33-9A738E100545 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Yes, I meant cornered. But it turns out it works worse in my case, I get paths with hundreds of = segments and a run that goes amok. But that made me find a mistake in my = code and now I=E2=80=99m using my own again and it works fine: vardef softenPath( expr hardPath) =3D save softPath; path softPath; save len; len :=3D length hardPath; save rounding; rounding :=3D 5; save i; for i=3D0 upto len: if (i=3D0): % first pair softPath :=3D point i of hardPath; elseif (i=3Dlen): % lastpair softPath :=3D softPath -- point i of hardPath; else: % intermediate pair save subOne; path subOne; subOne :=3D subpath(i-1, i) of hardPath; save subTwo; path subTwo; subTwo :=3D subpath(i, i+1) of hardPath; save lenOne; numeric lenOne; lenOne :=3D arclength subOne; save lenTwo; numeric lenTwo; lenTwo :=3D arclength subTwo; save pointOne, pointTwo; pair pointOne, pointTwo; pointOne :=3D point (arctime (lenOne-rounding) of subOne) of = subOne; pointTwo :=3D point (arctime rounding of subTwo) of subTwo; save dirOne, dirTwo; pair dirOne, dirTwo; dirOne :=3D direction (arctime (lenOne-rounding) of subOne) of = subOne; dirTwo :=3D direction (arctime (rounding) of subTwo) of subTwo; softPath :=3D softPath -- pointOne{dirOne} .. {dirTwo}pointTwo; fi endfor; softPath enddef; Fixed rounding of 5bp, but that is easy to change. > On 5 Apr 2020, at 12:37, Wolfgang Schuster = wrote: >=20 > Gerben Wierda schrieb am 05.04.2020 um 12:31: >> I think I saw a function in MetaFun somehwre that you could give a = =E2=80=98hard=E2=80=99 path, i.e. (0,0) -- (0,1) =E2=80=94 (1,1) and it = would become a path with nicely rounded (part of a circle) corners = (still straight lines), but I can=E2=80=99t find it anymore. I wrote my = own, but it is giving me headaches so I=E2=80=99d like to find something = that is better than what I produce. >=20 > You you mean "cornered ..." or "smoothed ..."? >=20 > Wolfgang --Apple-Mail=_CD7B8EDF-B8B9-4D78-9F33-9A738E100545 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Yes, = I meant cornered.

But = it turns out it works worse in my case, I get paths with hundreds of = segments and a run that goes amok. But that made me find a mistake in my = code and now I=E2=80=99m using my own again and it works fine:

vardef softenPath( expr hardPath) =3D
  save = softPath; path softPath;
  save len; len :=3D length = hardPath;
  save = rounding; rounding :=3D 5;
  save i;
  for i=3D0 upto len:
  =   if (i=3D0):
    =   % first pair
      softPath :=3D point i of = hardPath;
    = elseif (i=3Dlen):
      % lastpair
      softPath :=3D softPath -- point = i of hardPath;
    = else:
    =   % intermediate pair
      save subOne; path subOne; subOne :=3D = subpath(i-1, i) of hardPath;
      save subTwo; path subTwo; subTwo :=3D = subpath(i, i+1) of hardPath;
      save lenOne; numeric lenOne; lenOne :=3D = arclength subOne;
      save lenTwo; numeric lenTwo; lenTwo :=3D = arclength subTwo;
      save pointOne, pointTwo; pair pointOne, = pointTwo;
    =   pointOne :=3D point (arctime (lenOne-rounding) of subOne) of = subOne;
    =   pointTwo :=3D point (arctime rounding of subTwo) of = subTwo;
    =   save dirOne, dirTwo; pair dirOne, dirTwo;
      dirOne :=3D direction (arctime = (lenOne-rounding) of subOne) of subOne;
      dirTwo :=3D direction (arctime = (rounding) of subTwo) of subTwo;
      softPath :=3D softPath -- = pointOne{dirOne} .. {dirTwo}pointTwo;
    fi
  endfor;
  softPath
enddef;

Fixed rounding of 5bp, but that is easy = to change.

On 5 Apr 2020, at 12:37, Wolfgang Schuster = <wolfgang.schuster.lists@gmail.com> wrote:

Gerben= Wierda schrieb am 05.04.2020 um 12:31:
I think I saw a function in MetaFun somehwre = that you could give a =E2=80=98hard=E2=80=99 path, i.e. (0,0) -- (0,1) = =E2=80=94 (1,1) and it would become a path with nicely rounded (part of = a circle) corners (still straight lines), but I can=E2=80=99t find it = anymore. I wrote my own, but it is giving me headaches so I=E2=80=99d = like to find something that is better than what I produce.

You you mean "cornered ..." or = "smoothed ..."?

Wolfgang

= --Apple-Mail=_CD7B8EDF-B8B9-4D78-9F33-9A738E100545-- --===============8215992499387737160== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============8215992499387737160==--