HoloDraw Program Documentation: drawpars

Documentation | Download | Examples | Frequently Asked Questions (FAQ)

Program Summary

Filename drawpars.ps
Author Marvin Simkin
Program Created 2003-07-09
Last Updated Jan 28 12:44
Purpose draw file parser
syntax require 'drawpars.ps';
search for "{ package" in source code for interface details

Discussion

This file contains a collection of subroutines that
support a "draw file format" intended to make it easier to
create "Virtual Reality" images. Some Virtual Reality languages (e.g. VRML)
can be rather verbose. "draw" files can be 10 to 100 times smaller, making
it reasonable for you to type them by hand or generate them by making
trivial modifications to a data file. The tradeoff is that you can't do
everything with a draw file that you can with VRML. Of course, if you want
to use all the features of VRML, there's a quite nice language for that
already, called ... VRML.

The goal of the draw file format is to make it possible to describe an
object in a one-line instruction (e.g. draw a line from point A to point B)
and to set defaults that apply to all subsequent objects (e.g. color red).
Because everything relevant is included in that single line, you can use
Unix text utilities like grep, awk, sed, cut, sort and so on to create and
manipulate your draw files.

You can have one "phrase" per line, or multiple "phrases" separated by ;
A phrase describing an object has a colon, such as "line:X1 Y1 Z1,X2 Y2 Z2".
This immediately causes the object to be created with existing colors etc.
Or a phrase can set a value with an equal sign, such as "color=R G B".
When a phrase changes a value it applies to all subsequent instructions.

Input data format example
=========================
color=1 0 0
linewidth=3
line:X1 Y1 Z1,X2 Y2 Z2
line:X1 Y1 Z1,X2 Y2 Z2;line:X1 Y1 Z1,X2 Y2 Z2,X3 Y3 Z3,X4 Y4 Z4,X5 Y5 Z5
color=0 0 1
line:X1 Y1 Z1,X2 Y2 Z2
polygon:X1 Y1 Z1,X2 Y2 Z2,X3 Y3 Z3
point:X1 Y1 Z1
linewidth=1;line:X1 Y1 Z1,X2 Y2 Z2
color=0.2 0.2 0.2;line:X1 Y1 Z1,X2 Y2 Z2
fontname=Times-Roman;fontheight=12;fontjust=CENTER
text:X1 Y1 Z1,whatever you want to say here
=========================
Here's what each line does:
(1) set the default color for subsequent objects to RED.
(2) all subsequent lines shall be 3 pixels wide (VRML 1 only)
(3) draw a line (it will be red and 3 pixels wide)
(4) draw two more red lines
(5) change the color to blue for subsequent objects
(6) a blue line
(7) a blue triangle
(8) a blue point
(9) a blue line but only one pixel wide
(10) use gray from now on; draw a gray line
(11) display the phrase in gray text

DISCLAIMER:
This doesn't claim to be a stellar example of perl coding or anything else
for that matter. But it works for me.


Written by Marvin Simkin
Filename drawpars.html
Last updated April 5, 2005
Arizona State University Valid HTML 4.01!
Freedom to Choose ANY Browser