Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3412

Re: Fierce and scary geometry algorithm for ‘ParallelPath’

Newsgroups comp.lang.postscript
Date 2019-06-27 06:59 -0700
References (4 earlier) <a837e718-be44-4ff9-bd4c-e06c86e2e80e@googlegroups.com> <75b8871c-908d-42db-bd69-5737a3a4c29a@googlegroups.com> <8b884955-fcb0-4951-a046-2de625237289@googlegroups.com> <a5fe9001-8442-44a6-9092-14ec7abbc217@googlegroups.com> <839f314e-3b66-4227-b19c-b13ad697f6d8@googlegroups.com>
Message-ID <f33ac85c-3814-49a2-82a5-ee72a8fdd8ff@googlegroups.com> (permalink)
Subject Re: Fierce and scary geometry algorithm for ‘ParallelPath’
From luser droog <luser.droog@gmail.com>

Show all headers | View raw


On Sunday, June 23, 2019 at 5:59:51 PM UTC-5, luser droog wrote:
> 
> Using Calibri looks a little better, although apparently the orientation
> is the reverse of what Palatino-Bold uses. I discovered that by doing
> 
>   /Calibri-Bold 596 selectfont
>   100 100 moveto (9) true charpath
>   1 setlinejoin
>   flattenpath
>   20 setlinewidth strokepath
>   %dumppath                                                                                                                                                                                                                       
>   0 setlinewidth
>   stroke showpage
> 
> Then the dumppath nicely shows where the joins are (they're the curves).
> But I haven't come up with a way to exploit that knowledge yet.
> The image shows little hemispheres at each join.

After seeing a nice example of 'arcto', I rewrote my code to try to get
something where I could drop in an 'arcto' to clean up the output.
Sort of a step sideways. This program exhibits the same problems as the
earlier ones, but it no longer uses the result of 'strokepath' so it's
no longer implementation dependant. Instead it's dependent on the font
glyph itself, expecting several closed paths followed by a lone 'moveto'
at the end.

This program draws the original glyph, then the 'strokepath' scaffolding,
then my curve at the same width in red, then another curve farther out in
blue. The blue one makes it easier to see the problems going on in the red
one.

$ cat stroke1.ps
%!

/closedsubpaths {
  [
    { [ 3 1 roll }
    { }
    { }
    { ] }
    pathforall
  ] ]
} def

/div {
  dup 0 eq { pop }{//div} ifelse
} def

/perp {
  {y1 x1 y0 x0}{exch def}forall
  x1 x0 sub y1 y0 sub
  exch neg % dx,dy => dy,-dx
  2 copy dup mul exch dup mul add sqrt
  2 copy div % x y mag y/mag
  4 1 roll exch pop div exch % x/mag y/mag
} def


/offsetvectorsbyn {
  [ exch
    { %forall subpaths
      dup length 2 gt {
      [ exch
        %pstack()=
        0 2 2 index length 4 sub { % A i
            2 copy 4 getinterval aload pop % A i x0 y0 x1 y1
            perp n mul exch n mul exch % A i dx dy
            4 copy pop pop 2 getinterval aload pop % A i dx dy xi yi
            exch 4 3 roll add % A i dy yi xi'
            3 1 roll add % A i xi' yi'
            4 2 roll pop
        } for  % [ ... A
        dup dup length 2 sub 2 getinterval aload pop 2 copy
        5 4 roll  0 2 getinterval aload pop
        %counttomark 1 sub index counttomark 2 sub index
        perp n mul exch n mul exch
        exch 4 3 roll add
        3 1 roll add
      ]
      }{ pop } ifelse
    } forall
  ]
} def

/drawpath {
  {
     dup 0 2 getinterval aload pop moveto
     2 1 index length 2 sub getinterval
     0 2 2 index length 1 sub { % A i
       2 copy 2 getinterval aload pop lineto
       pop
     } for pop
     closepath
  } forall
} def

/offsetpath {
  /n exch def
  closedsubpaths
  %pstack quit
  offsetvectorsbyn
  newpath
  drawpath
} def

/Calibri-Bold 596 selectfont
100 100 moveto (9) true charpath
gsave stroke grestore
20 setlinewidth
strokepath
1 setlinewidth
stroke

1 0 0 setrgbcolor
100 100 moveto (9) true charpath
flattenpath
10 offsetpath
3 setlinewidth 
stroke

0 0 1 setrgbcolor
100 100 moveto (9) true charpath
flattenpath
20 offsetpath
stroke

showpage quit

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Fierce and scary geometry algorithm for ‘ParallelPath’ jdawiseman.bloomberg@gmail.com - 2019-04-17 13:37 -0700
  Re: Fierce and scary geometry algorithm for ‘ParallelPath’ edspikechapman@gmail.com - 2019-04-19 08:55 -0700
    Re: Fierce and scary geometry algorithm for ‘ParallelPath’ jdawiseman.bloomberg@gmail.com - 2019-04-20 02:44 -0700
      Re: Fierce and scary geometry algorithm for ‘ParallelPath’ Carlos <carlos@cvkm.cz> - 2019-04-29 02:41 +0200
        Re: Fierce and scary geometry algorithm for ‘ParallelPath’ jdaw1 <jdawiseman@gmail.com> - 2019-06-19 15:04 -0700
          Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-22 13:33 -0700
            Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-22 14:54 -0700
              Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-22 15:37 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-23 15:59 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-27 06:59 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-27 07:48 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-27 08:30 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-06-28 12:10 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-07-19 14:00 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-07-20 09:33 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-07-20 13:20 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ jdaw1 <jdawiseman@gmail.com> - 2021-03-14 10:25 -0700
  Re: Fierce and scary geometry algorithm for ‘ParallelPath’ jdawiseman.bloomberg@gmail.com - 2019-04-20 06:54 -0700
    Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-04-20 10:44 -0700
      Re: Fierce and scary geometry algorithm for ‘ParallelPath’ jdawiseman.bloomberg@gmail.com - 2019-04-20 11:01 -0700
        Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-04-20 11:33 -0700
          Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-04-20 11:50 -0700
            Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-04-20 13:01 -0700
              Re: Fierce and scary geometry algorithm for ‘ParallelPath’ jdawiseman.bloomberg@gmail.com - 2019-04-21 03:29 -0700
                Re: Fierce and scary geometry algorithm for ‘ParallelPath’ luser droog <luser.droog@gmail.com> - 2019-04-28 13:33 -0700

csiph-web