%!PS-Adobe-2.0
%%Pages: 0 1
%%BoundingBox: 0 0 612 792
%%EndComments
% display version of slide rule
/r_basic 200 def
/r r_basic def
/tempstr3 3 string def % for writing value to a string
/arg1 2 def % move inner to arg1
/arg2 8 def % move pointer to arg2

0.5 setlinewidth
/Green{0.05  0  0.05  0 setcmykcolor} def
/Blue{0.05  0.05  0 0 setcmykcolor} def
/Red{0 1 1 0 setcmykcolor} def
/Black{0 0 0 1 setcmykcolor} def

/degree { % stack: a
  log 360 mul neg
} def

/circle {
  newpath
  -296 -296 moveto 592 0 rlineto 0 610 rlineto
    -592 0 rlineto closepath 
  gsave
    Green fill
  grestore
  stroke
  %newpath -296 310 moveto 592 310 lineto stroke

  newpath 0 0 r 0 360 arc
  gsave
    Blue fill
  grestore
  stroke
} def

/center {
  % put circle at center
  newpath 0 0 6 0 360 arc stroke
  0 -10 moveto 0 10 lineto stroke
  -10 0 moveto 10 0 lineto stroke
} def % center

/mark { % stack: a t1 code
  /code exch def % code lt 0, reverse circle
  /t1 exch def % line length
  /a exch def % number
  /s r t1 add def
  /ang { a degree } def
  code 0 lt {
    /ang ang neg def
  } if
  /code code abs def
  gsave
    ang rotate
    0 r moveto
    0 s lineto
    stroke
  grestore
} def % mark

/name { % stack: a t1 f1 code
  /code exch def % code lt 0, reverse circle
  /f1 exch def % font size
  /t1 exch def % line length
  /a exch def % number
  /s r t1 add def
  /ang { a degree } def
  code 0 lt {
    /ang ang neg def
  } if
  /code code abs def
  gsave
    ang rotate
    0 s moveto
    code 1 eq {
      /Helvetica findfont f1 scalefont setfont
      a tempstr3 cvs stringwidth pop 2 div neg 0 rmoveto
      a tempstr3 cvs show
    } if
    code 2 eq {
      /Symbol findfont f1 scalefont setfont
      (p) stringwidth pop 2 div neg 0 rmoveto
      (p) show
    } if
    code 3 eq {
      /Helvetica findfont f1 scalefont setfont
      (e) stringwidth pop 2 div neg 0 rmoveto
      (e) show
    } if
  grestore
} def % name

/markA { % stack: a t1 mult
  /mult exch def % 2 for A, 3 for K
  /t1 exch def % line length
  /a exch def % number
  /t0 15 def % amt below mark
  /s r t1 add def
  /ang { a degree} def
  gsave
    ang mult div rotate
    0 r moveto
    0 s lineto
    stroke
  grestore
} def % markA

/nameA {% stack: a t1 f1 mult
  /mult exch def % 2 for A, 3 for K
  /f1 exch def % font size
  /t1 exch def % line length
  /a exch def % number
  /s r t1 add def
  /ang { a degree} def
  gsave
    ang mult div rotate
    0 s moveto
    /Helvetica findfont f1 scalefont setfont
    a tempstr3 cvs stringwidth pop 2 div neg 0 rmoveto
    a tempstr3 cvs show
  grestore
} def % nsameA

/drawC {
  % put in pointer
  0.7 setgray
  newpath 0 r moveto -20 r 40 add lineto 40 0 rlineto closepath fill
  0 setgray
  10 r 10 add moveto
  /Helvetica findfont 20 scalefont setfont
  (C) show
  1    1     9   { 8 0 mark } for
  1.1  0.1   2   { 10 0 mark } for
  2.5  1     9.5 { 10 0 mark } for
  1.05 0.1   2   { 8  0 mark } for
  2    0.1   5   { 10 0 mark } for
  2    0.05  5   { 8  0 mark } for
  2    0.025 5   { 5  0 mark } for
  1    0.01  2   { 5  0 mark } for
  5    0.1   10  { 10 0 mark } for
  5    0.05  10  { 5  0 mark } for

  1    1     9   { 10 15 1 name } for
  1.1  0.1   2   { 12 9  1 name } for
  2.5  1     9.5 { 12 9  1 name } for

  3.14159 14 12 2 name
  2.71828 14 12 3 name
  3.14159 12 0 mark
  2.71828 12 0 mark
} def

/drawCI {
  /r r_basic 30 add def
  1    1     9   { 10 -1 mark } for
  1.1  0.1   2   { 10 -1 mark } for
  2.5  1     9.5 { 10 -1 mark } for
  1.05 0.1   2   { 8  -1 mark } for
  2    0.1   5   { 12 -1 mark } for
  2    0.05  5   { 8  -1 mark } for
  2    0.025 5   { 5  -1 mark } for
  1    0.01  2   { 5  -1 mark } for
  5    0.1   10  { 10 -1 mark } for
  5    0.05  10  { 5  -1 mark } for
  Red
  1    1     9   { 12 15 -1 name } for
  1.1  0.1   2   { 12 9 -1 name } for
  2.5  1     8.5 { 12 9 -1 name } for

  10 r 11 add moveto
  /Helvetica findfont 20 scalefont setfont
  (CI) show
  Black
  /r r_basic def
} def

/drawD {
  % put in pointer
  0.7 setgray
  newpath 0 r moveto -20 r 40 sub lineto 40 0 rlineto closepath fill
  0 setgray
  8 r 26 sub moveto
  /Helvetica findfont 20 scalefont setfont
  (D) show
  1    1     9   { -10 0 mark } for
  1.1  0.1   2   { -10 0 mark } for
  2.5  1     9.5 { -10 0 mark } for
  1.05 0.1   2   { -8  0 mark } for
  2    0.1   5   { -12 0 mark } for
  2    0.05  5   { -8  0 mark } for
  2    0.025 5   { -5  0 mark } for
  1    0.01  2   { -5  0 mark } for
  5    0.1   10  { -10 0 mark } for
  5    0.05  10  { -5  0 mark } for

  1    1     9   { -23 15 1 name } for
  1.1  0.1   2   { -19 9  1 name } for
  2.5  1     9.5 { -19 9  1 name } for
} def

/drawA {
    /r r_basic 35 sub def
    8 r 20 sub moveto
    /Helvetica findfont 20 scalefont setfont
    (A) show
    1    1     9   { -8 2 markA } for
    1    0.05  2   { -3  2 markA } for
    1.1  0.1   2   { -6  2 markA } for
    2    0.5   6   { -8  2 markA } for
    2    0.1   6   { -4  2 markA } for
    5    0.2   10  { -4  2 markA } for

    1    1     9   { -20 12 2 nameA } for
    /r r_basic def
} def % drawA

/drawK {
    /r r_basic 65 sub def
    8 r 25 sub moveto
    /Helvetica findfont 20 scalefont setfont
    (K) show
    1    1     9   { -10 3 markA } for
    1    0.05  2   { -3 3 markA } for
    1.1  0.1   2   { -5 3 markA } for
    1    0.5   5   { -8 3 markA } for
    2    0.1   5   { -4 3 markA } for
    5    0.2   10  { -4 3 markA } for

    1    1     9   { -20 11 3 nameA } for
    /r r_basic def
} def % drawK

  /v r_basic 100 add def
  /w 30 def
  /t w w mul v v mul add sqrt def
  /th v w atan def

/pointer_path {
  newpath 0 0 w 180 360 arc w v lineto
  0 0 t th 180 th sub arc closepath
} def

/pointer {
  Red
  newpath 0 0 moveto 0 t lineto closepath stroke Black
  gsave
    pointer_path clip
    8 setlinewidth
    0.8 setgray
    pointer_path stroke
  grestore
  1 setlinewidth
  0 setgray
  pointer_path stroke
  newpath 0 0 6 0 360 arc fill
} def % pointer

/header {
  /HelveticaBold findfont 35 scalefont setfont
  -150 r 200 add moveto
  (Circular Slide Rule) show
  /HelveticaBold findfont 25 scalefont setfont
  -150 r 170 add moveto
  (Version: CD2, Demonstration) show
  /HelveticaBold findfont 12 scalefont setfont
  -150 r 150 add moveto
  ((Copyright 2015, Neal R. Wagner)) show
} def % header

8.5 72 mul 2 div 11 72 mul 2 div translate

/draw_all {
  circle
  center
  header

  /drawOuter {
    drawC
    drawCI
  } def % drawOuter

  /drawInner {
    drawD
    drawA
    gsave
      180 rotate
      drawA
    grestore

    drawK
    gsave
      120 rotate
      drawK
      120 rotate
      drawK
    grestore
  } def % drawInner

  drawOuter

  gsave
    arg1 degree rotate
    drawInner
  grestore

  gsave
    arg2 degree rotate
    pointer
  grestore
} def % draw_all

draw_all

showpage