[sdiy] dial graduations

Don Tillman don at till.com
Tue May 28 20:26:17 CEST 2002


   > Date: Tue, 28 May 2002 15:33:48 +0200
   > From: Andre Majorel <amajorel at teaser.fr>
   > 
   > On 2002-05-23 21:25 -0700, Don Tillman wrote:
   > 
   > >    > From: "Michael Ruberto" <frankentron at hotmail.com>
   > >    > Date: Thu, 23 May 2002 21:46:25 -0400
   > >    > 
   > >    > I am in the process of designing front panel graphics for all of
   > >    > my modules so I can have them laser etched. the biggest problem
   > >    > so far is creating the tick marks to go around the knobs. I am
   > >    > doing it "by hand" in photoshop but it is really quite time
   > >    > consuming. is hand drawing these the only way to go?  
   > > 
   > > This is very easy to do in raw PostScript. 
   > 
   > Interesting. Would you care to post a code fragment, for those
   > of us who don't mumble PostScript in their sleep ?

(Hey, you wouldn't ask this of that guy who suggests doing everything
with a PIC!)

Below is a PostScript program for drawing three dial scales, complete
with center crosses.  See, it's easy.

Note that there are several very cool features about this approach.
It's accurate in the sense that you can say "I want this switch
*here*", where here is the measurement you specifcy with respect to any
other point you specify.  You can parameterize stuff, so that if you
decide later to change the style of something you only have to change
one parameter.  And you have complete control over everything.


----------------
initgraphics

%% scale to inches
72.0 72.0 scale

%% draw the center cross
/center-cross-size 0.25 def

/draw-center-cross {
    gsave
        1.0 72.0 div setlinewidth
        -0.5 center-cross-size mul 0.0 moveto
        +0.5 center-cross-size mul 0.0 lineto
        0.0 -0.5 center-cross-size mul moveto
        0.0 +0.5 center-cross-size mul lineto stroke
    grestore
} def

/dial-inside-radius 0.5 def
/dial-outside-radius 0.75 def
/dial-arc 270 def

%% draw a dial here
%% stack:
%%   n divisions
/draw-dial {
    gsave
        currentpoint translate
        draw-center-cross
        0 1 2 index
        {
            gsave
                1 index div dial-arc mul dial-arc 0.5 mul sub rotate
                0.0 dial-inside-radius moveto
                0.0 dial-outside-radius lineto stroke
            grestore
        } for
    grestore
    pop
} def
    
1.5 72.0 div setlinewidth

%% draw a few dials
2.0 8.0 moveto 10 draw-dial
4.0 8.0 moveto 10 draw-dial
6.0 8.0 moveto 10 draw-dial
showpage


----------------

  -- Don

-- 
Don Tillman
Palo Alto, California, USA
don at till.com
http://www.till.com




More information about the Synth-diy mailing list