From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107193 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Re: followtext, lmt_followtext and an offset of the glyphs typeset along the path (suggestion works) Date: Sun, 3 May 2020 17:52:00 +0200 Message-ID: References: <9C072F4C-A2EB-4B57-B4A7-A45321A2617E@rna.nl> <69BD595D-F6CA-47F4-86D4-2428A2ABF893@scorecrow.com> <106114AC-5BC6-4CF2-A1C8-03262138DA46@rna.nl> 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="===============5009901763921314098==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="73009"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun May 03 17:52:22 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 1jVGuk-000IsM-05 for gctc-ntg-context-518@m.gmane-mx.org; Sun, 03 May 2020 17:52:22 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 69F31183148; Sun, 3 May 2020 17:52:05 +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 WHmb1aRbNx8N; Sun, 3 May 2020 17:52:04 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5B86D1839E2; Sun, 3 May 2020 17:52:04 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B926F1839DD for ; Sun, 3 May 2020 17:52:03 +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 q4AMYjp8J3XU for ; Sun, 3 May 2020 17:52:02 +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 4738D183148 for ; Sun, 3 May 2020 17:52:02 +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 8D8893E0ECFD for ; Sun, 3 May 2020 17:52:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1588521120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n0K3YoMY4Q8MRnNDmHCFyie3CZjUsYHVLKeVjldUCbA=; b=prwCWHhYcJ0+b5b8V37pCzlRDXIBRKbfFwu2BSCOClCLDzjEg8cAjqUc7OqAFwdyjutAI0 8YKWANaDORyoMpk09RVnBTQq/Cf1ZikBkNgs3aSn2xCtiIFhVdlUKt8Yp8LbBzFQug9pp7 jq2pqVDIYqU1mZbcd1ctxPOPUjoeLZX1OAtlFQqeOZS5LfK49NkxHL/JhTqFG1eCryi7R5 WodMmFyMi7zu6zY7Y5aD5RO/tkLizXlgR5JDTsZomjdSe9hyYsxbuvTAMU8Af/etigyA8j ohrCX+SB88AIMHSH0plbRnc20OocYf7QEZ1YUV3Cb7qFUsb4fjTv9QukP0o+og== In-Reply-To: <106114AC-5BC6-4CF2-A1C8-03262138DA46@rna.nl> 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:107193 Archived-At: --===============5009901763921314098== Content-Type: multipart/alternative; boundary="Apple-Mail=_2B370313-3496-4D37-93AA-FA542897B41D" --Apple-Mail=_2B370313-3496-4D37-93AA-FA542897B41D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 3 May 2020, at 15:01, Gerben Wierda wrote: >=20 >>>>> Am 01.05.2020 um 10:26 schrieb Gerben Wierda >: >>>>>=20 >>>>> I have been looking at lmt_followtext and followtext to get = typesetting done along a path. That works fine, except that in my case, = I need the text to not be exactly on that path, I need it to hover = slightly above tor below he path. Given that the path may have an = unpredictable form, that means that all the glyphs need to be shifted a = bit, there is no generic transfrom of the entire text string that will = work, >>>>=20 >>>> Can=E2=80=99t you duplicate and shift the path, i.e. keep the = original visible and make the copy that carries the text invisible? = That=E2=80=99s what I would do in a graphical application, but I would = be surprised if MP wouldn=E2=80=99t know a transformation for this = purpose. >>>=20 >>> No, that is what I did in the example, fiddling, but there is no = transformation that will work in all cases. E.g. on the left side of the = bump, I need to go to the upper left, on the right side to the upper = right. There is no single shift that helps me. Nor a scale rotation or = shift combination. That could be managed by only going up (though the = distance to the path would vary, on the sides the text would be very = close or on the top it would be too far.) >>>=20 >>=20 >> There is an example, at the link below, of creating a parallel path = that claims to cope with sharp bends in the original path. You might be = able to adapt it? >> = > >=20 > That looks great. I=E2=80=99m going to investigate. That approach works fine. Example trial code: \starttext \startMPpage vardef parallelpath (expr P, gap)=3D % adapted from = https://therion.speleo.sk/wiki/metapost#shuttering_two_parallel_lines save pathlength, linegap, testdiameter, testpath, innerpath, newpoint, = curlength, intersections, samplepoint, sampledir, accuracy; % work out a parallel path % the easy way is to sample direction every few units, and add a = parallel point into a new path % however, this causes weird loops at sharp corners, so check if a = sharp corner is coming up within % the length of the gap between lines, and ignore that point if so pathlength:=3Darclength P; linegap:=3Dgap; accuracy:=3D2; testdiameter:=3Dlinegap; path testpath; testpath:=3D(halfcircle rotated 180) scaled testdiameter; pair newpoint; pair sampledir; path innerpath; pair intersections; curlength:=3D0; forever: samplepoint:=3Darctime curlength of P; sampledir:=3Ddirection samplepoint of P; newpoint:=3D((point samplepoint of P) shifted (linegap * = unitvector(sampledir rotated -90))); if curlength =3D 0: innerpath:=3Dnewpoint{sampledir}; fi % every now and then along the line, place a semicircle, rotated to = face away from the line, offset by the thickness of the line, % with a radius the same as the gap between the lines - if its ends = touch the main line's centre, the corner is too sharp to use % this point save truetestpath; path truetestpath; truetestpath :=3D (testpath = rotated (angle sampledir) shifted (point samplepoint of P)); intersections:=3DP intersectiontimes truetestpath; % if there are no intersections, intersectiontimes returns (-1,-1), = otherwise it returns the distance along each path (P,testpath) % where the intersection happened >=3D0 if (xpart intersections) =3D -1: show "ADDED", newpoint{sampledir}; innerpath:=3Dinnerpath .. newpoint{sampledir}; else: show "REJECTED", newpoint{sampledir}; draw truetestpath withcolor green withtransparency (1,0.1); fi; exitif curlength =3D pathlength; % move in small steps, to take account of tight backwards curves, = and to get points near a corner curlength:=3Dcurlength + testdiameter/accuracy; if curlength > pathlength: curlength:=3Dpathlength; fi; endfor; if known innerpath: if cycle P: innerpath:=3Dinnerpath .. cycle; fi; fi; innerpath enddef; path testIn, testOut; testIn :=3D (0,0)..(100,50)..(50,100)..(130,0); testOut :=3D parallelpath( testIn, 2); draw testIn withpen pencircle scaled 1; %draw testOut withpen pencircle scaled 1 withcolor red; draw lmt_followtext [ text =3D "How well does it work? {\it It works very well!} {\bf It = looks good enough.}", path =3D reverse testOut, spread =3D false, ]; Going to work with it. Thanks again. G --Apple-Mail=_2B370313-3496-4D37-93AA-FA542897B41D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = 3 May 2020, at 15:01, Gerben Wierda <gerben.wierda@rna.nl> wrote:

Am 01.05.2020 um 10:26 schrieb Gerben Wierda <gerben.wierda@rna.nl>:

I = have been looking at lmt_followtext and followtext to get typesetting = done along a path. That works fine, except that in my case, I need the = text to not be exactly on that path, I need it to hover slightly above = tor below he path. Given that the path may have an unpredictable form, = that means that all the glyphs need to be shifted a bit, there is no = generic transfrom of the entire text string that will work,

Can=E2=80=99t you duplicate and = shift the path, i.e. keep the original visible and make the copy that = carries the text invisible? That=E2=80=99s what I would do in a = graphical application, but I would be surprised if MP wouldn=E2=80=99t = know a transformation for this purpose.

No, that is what I did in the example, fiddling, but there is = no transformation that will work in all cases. E.g. on the left side of = the bump, I need to go to the upper left, on the right side to the upper = right. There is no single shift that helps me. Nor a scale rotation or = shift combination. That could be managed by only going up (though the = distance to the path would vary, on the sides the text would be very = close or on the top it would be too far.)


There is an example, at the link below, of creating a = parallel path that claims to cope with sharp bends in the original path. = You might be able to adapt it?
<https://therion.speleo.sk/wiki/metapost#shuttering_two_parallel= _lines>

That looks great. I=E2=80=99m going to = investigate.

That approach works fine. Example trial = code:

\starttext

\startMPpage
vardef parallelpath (expr P, gap)=3D
  % = adapted from https://therion.speleo.sk/wiki/metapost#shuttering_two_parallel= _lines
  save pathlength, linegap, testdiameter, = testpath, innerpath, newpoint, curlength, intersections, samplepoint, = sampledir, accuracy;
  % work out a parallel path
  % the easy way is to sample direction every few units, = and add a parallel point into a new path
  % however, = this causes weird loops at sharp corners, so check if a sharp corner is = coming up within
  % the length of the gap between = lines, and ignore that point if so
  = pathlength:=3Darclength P;
  linegap:=3Dgap;
  accuracy:=3D2;
  = testdiameter:=3Dlinegap;
  path testpath;
  testpath:=3D(halfcircle rotated 180) scaled = testdiameter;
  pair newpoint;
  = pair sampledir;
  path innerpath;
  = pair intersections;
  curlength:=3D0;
  forever:
    = samplepoint:=3Darctime curlength of P;
    = sampledir:=3Ddirection samplepoint of P;
    = newpoint:=3D((point samplepoint of P) shifted (linegap * = unitvector(sampledir rotated -90)));
    if = curlength =3D 0:
      = innerpath:=3Dnewpoint{sampledir};
    fi
    % every now and then along the line, place a = semicircle, rotated to face away from the line, offset by the thickness = of the line,
    % with a radius the same as the = gap between the lines - if its ends touch the main line's centre, the = corner is too sharp to use
    % this point
    save truetestpath; path truetestpath; = truetestpath :=3D (testpath rotated (angle sampledir) shifted (point = samplepoint of P));
    intersections:=3DP = intersectiontimes truetestpath;
    % if there = are no intersections, intersectiontimes returns (-1,-1), otherwise it = returns the distance along each path (P,testpath)
  =   % where the intersection happened >=3D0
  =   if (xpart intersections) =3D -1:
    =   show "ADDED", newpoint{sampledir};
    =   innerpath:=3Dinnerpath .. newpoint{sampledir};
 =   else:
      show "REJECTED", = newpoint{sampledir};
      draw = truetestpath withcolor green withtransparency (1,0.1);
    fi;
    exitif = curlength =3D pathlength;
    % move in small = steps, to take account of tight backwards curves, and to get points near = a corner
    curlength:=3Dcurlength + = testdiameter/accuracy;
    if curlength > = pathlength:
      curlength:=3Dpathlength;    fi;
  endfor;
  if known innerpath:
    if = cycle P:
      innerpath:=3Dinnerpath .. = cycle;
    fi;
  fi;
  innerpath
enddef;

path testIn, testOut;

testIn :=3D = (0,0)..(100,50)..(50,100)..(130,0);
testOut :=3D = parallelpath( testIn, 2);

draw testIn = withpen pencircle scaled 1;
%draw testOut withpen = pencircle scaled 1 withcolor red;
draw lmt_followtext [
  text =3D "How well does it work? {\it It works very = well!} {\bf It looks good enough.}",
  path =3D = reverse testOut,
  spread =3D false,
];

Going to = work with it. Thanks again.

G

= --Apple-Mail=_2B370313-3496-4D37-93AA-FA542897B41D-- --===============5009901763921314098== 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== --===============5009901763921314098==--