Fractals Continued

Author(s): Duane Ellis
Publication: The Data Expansion
Pub Details: The Data Expansion v5 n6 (Volume 5, Issue 6)
Date: June 1988
Pages: 21-22

A Quick Review

By now, we have most of the program defined. We are missing some parts, but.. we can at least get a start on the program. Before we go too far, let’s review:

1) (From last month) Given a color number, ranging from color 0 to 255, you can print that color in black or white. Remember, ODD colors are BLACK, EVEN are WHITE, we have not GREY’s. We use MODULUS DIVISION to do this.

2) (From last month) Given a screen position, or printer position in X, Y (row, column) form, you can find its WORLD location. The big formula at the end of the last article.

3) We are going to draw the picture ONE row at a time. Basically, that means ONE swipe of the print head at a time.

4) It is going to work when we are done, and it is “A program that I understand, not a program you type out of a magazine and con not figure out.”

Psuedo Code

When ever you design a program you always psuedo code, we are going to start at the TOP and work our way DOWN into the program.

Ask the user the range of the drawing.
Tell the user to prepare the printer.
FOR each row on the printer page
     FOR each position on the current row
          FOR each dot on the print head
               Transform the dot's page location X, Y to its
World X, Y
               Find the color of the current dot
          Do the NEXT dot on the print head
          Send the information to the printer.
     Move to the NEXT print head position.
Do the NEXT row on the page.
Tell the user we are done drawing the picture.

FINALLY SOME CODE

OK, we are ready for some code. Here’s the start of our program.

100 'Fractal Plotter Version 1.0, Public Domain
110 'Written by Duane Ellis for the Pittsburgh Area Computer
Club
120 'The variables we are going to use are:
130 'WR,WL,WT,WB=The World Left,Right,Top,&Bottom
140 'VR,VL,VT,VB=The View Left,Right,Top,&Bottom
150 'The VR,VL,VT,VB are really the locations on the printed
page
160 'That corresponds to the World position
170 'PD is the Print Head Dot number we are examining
180 'MDOTS is the maximum number of dots on the print head
190 'PX,PY are the print head dot X and Y position on the page
200 'ROW,COL the row and column the print head is at
210 'MROW,MCOL the Maximum Row and Column the printer supports
220 'CX,CY are the Current X and Y that we are examining
230 'WX,WY are the World X and Y locations these represent.
240 GOSUB 1000 'Ask the user the range of the plot
250 GOSUB 2000 'Get printer ready and wait til it is
260 FOR ROW=0 TO MROM
270 GOSUB 3000 'Prepare the printer for a row of graphics
280 FOR COL=0 TO MCOL 'For each column on this row
290 FOR PF=0 TO MDOTS
300 GOSUB 4000 'Turn ROW,COL&Print head dot to
Printer X,y
310 GOSUB 5000 'Turn Printer X,Y to Current X,Y
320 GOSUB 6000 'Find World X,Y values
330 GOSUB 7000 'Find the color of this dot (Black or
White)
340 GOSUB 8000 'Save the dot value for now
350 NEXT PD 'Next dot on the print head
360 GOSUB 9000 'Send the current dots to the printer
370 NEXT COL 'Next column on this row
380 GOSUB 10000 'Tell the printer to move down one row
390 NEXT ROW 'Go do the next row
400 PRINT "Plot complete"
410 END

Yes, there is a lot missing here (namely lines 1000 to 10000). We will develop those as we go along. For now, what I would suggest is dig out out printer manual and play around with some of those example programs in the back of your printer manual.

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.