From: Kerry Anderson Subject: a BASIC program to create HPGL hexes On Mon, 16 Dec 1996, Roberts Paul wrote: > Thanks, Kerry. > > BTW, the use of a HPGL hex grid would be useful, please. > I kind of hacked this together a couple of weeks ago. There's lots of room for improvement. HPGL is Hewlett Packard graphics language. Most sophisticated vector drawing packages are capable of importing these files. I do not nor have never owned a manual so the code is a copy-cat of data exported in HPGL. I simply mimicked commands... ---------------------------------------------------------------------- ' Kerry Anderson excellent HPGL hex generation program ' pi = 3.1415926# hexsize = 5 / 8 'HPGL coordinate points per inch? pts = 1000 'Calculate sin/cos/hyp relationship wrt HPGL coordinate points c = hexsize * pts / 2 s = hexsize * pts / 2 / SQR(3) h = hexsize * pts / 2 * 2 / SQR(3) 'Open output file and write some preliminary stuph OPEN "O", #1, "b:hexes.plt" PRINT #1, "IN;" PRINT #1, "VS32,1;" PRINT #1, "VS32,2;" PRINT #1, "VS32,3;" PRINT #1, "VS32,4;" PRINT #1, "VS32,5;" PRINT #1, "VS32,6;" PRINT #1, "VS32,7;" PRINT #1, "VS32,8;" PRINT #1, "WU0;" PRINT #1, "PW0.350,1;" PRINT #1, "PW0.350,2;" PRINT #1, "PW0.350,3;" PRINT #1, "PW0.350,4;" PRINT #1, "PW0.350,5;" PRINT #1, "PW0.350,6;" PRINT #1, "PW0.350,7;" PRINT #1, "PW0.350,8;" PRINT #1, "SP1;" 'First centre point for Tabloid xstart = 8.5 * pts ystart = 11 * pts FOR i = 1 TO 19 FOR j = 1 TO 26 x = xstart - 2 * c * (j - 1) y = ystart - (h + s) * (i - 1) IF i \ 2 = i / 2 THEN x = x + c PRINT #1, "PU" + LTRIM$(STR$(CINT(x + c))) + STR$(CINT(y - s)) + ";" PRINT #1, "PD" + LTRIM$(STR$(CINT(x + c))) + STR$(CINT(y + s)) + ";" PRINT #1, "PD" + LTRIM$(STR$(CINT(x))) + STR$(CINT(y + h)) + ";" PRINT #1, "PD" + LTRIM$(STR$(CINT(x - c))) + STR$(CINT(y + s)) + ";" PRINT #1, "PD" + LTRIM$(STR$(CINT(x - c))) + STR$(CINT(y - s)) + ";" PRINT #1, "PD" + LTRIM$(STR$(CINT(x))) + STR$(CINT(y - h)) + ";" PRINT #1, "PD" + LTRIM$(STR$(CINT(x + c))) + STR$(CINT(y - s)) + ";" NEXT j NEXT i PRINT #1, "SP0;" CLOSE #1