[comp.lang.postscript] SUMMARY: Re: Advice sought: drawing boxes faster

cosell@bbn.com (Bernie Cosell) (01/14/90)

Thanks for the neat suggestions.  In fact, as many people observed, I really
had a dual problem : 1) the boxes take a moderate amount of time to rlinto,
and fill in, and 2) the file gets to be so huge that at 9600 the transfer
time of the damn thing virutally dominates things.

On "drawing the boxes faster", there were lots of good ideas.  
  * The simplest one was just to stick a 'bind' into the defs.  
  * Another *wonderful* trick [which I tried, but haven't yet modified my 
    program to use] is to use "fat lines".  What a hack: you can draw 
    rectangles just with a setwidth of the appropriate fatness and 
    then drawing a line [e.g., to make a square, I'd just draw a zero-length 
    line].   
  * Putting in a a special "all squares font" looks like a good idea, 
    too... a bit complicated, but that's a part of PS that I've
    never messed with, so it'd probably be an interesting hack to push on
    [what a concept: instead of teh file being a huge collection of 
    "drawing" commands, it'd be little more than a big set of (string) 
    show's.  sigh].

As for making the file smaller, again lots of good ideas:
  * I cut the file in half [what a dummy I am!!] by the simple expedient of
    not drawing white boxes.  sigh.
  * I've 'run length encoded' the boxes [that is, instead of just a 'box'
    I have a 'rect' which takes a width].
  * I eliminated the rect-widths by precompiling specific width rects.
    that is, I have a family of rect2, rect3, rect4, ... each of which draws
    a rect of just the given width [and so I don't need to include the width
    explicitly when I use it].  It is actually done dynamically in the Unix
    program --- if I need a rect of width 'N', I see if I've already defined
    "rectN".  If not, I stick its 'def' right there.  So I only actually
    defined the specific widths I actually need.
  * of course all the names are shortened to one letter [using A = rect2,
    B = rect3, ... and using the lowercase letter for other little things].
  * use relative offsets for the routines, instead of absolute positioning
    [that is, use rmoveto instead of moveto to get from one to the next].
    Not only will that elimiate the constant repetition of the row number,
    but the numbers will be smaller [since the average delta with be one
    digit or two at most, while the absolute line position is two or three].
    I may also "precompile" these guys, too --- that is, have "rect2-7" be
    predefined to be "draw a rectangle two wide spaced seven from the last
    one".  Again, I can use my UNIX program to keep track of which
    widths-and-spacings I've needed and just define the ones I need.  That
    will reduce the file to being a bunch of /rectxxxx {} bind defs and
    calls on them... NO numbers will appear anywhere.  Almost as compact as
    doing the (string) show hack.

Anyway, I haven't implemented all of this, but I have put a fair amount of
these ideas into the UNIX program and it now has a 50 minute printing job
down to seven minutes, and that is about the transfer time at 9600 for the
file and so I can't tell how close I am on the processing time.  But... seven
minutes is more than fine enough and a lot better than I would have hoped I
could have achieved when I started.  Much thanks for the help and advice!!!

  /Bernie\