12.07.2015 Views

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

williams-et-al-1983-apple-ii-computer-graphics

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 11-GRAPHS AND CHARTS 123These lines select a random color for each bar. Line 520 prevents thenew color (C%) from being the same as the previous color (CO%) or colornumber 5. Color number 5 is excluded because there are two greys inLow-Res (colors 5 and 10).580 HTAB ( XS + 1) : VTAB (21)590 PRINT LEFT$ (LBL$(I), WB%) ;These position the cursor at the correct place and print as much of thelabel as will fit in the width of the bar.600 FOR X = XS TO XS + WB%-1610 IF X > 39 THEN PRINT CHR$ (7) ; "CHART TOO WIDE" :GOTO 670620 IF H% THEN HLIN 0 , BAR(I) * SCL AT X630 IF NOT (H%) THEN VLIN 39,39-BAR(I) * SCL AT X64 NEXT XThis loop draws the bar. If you selected a horizont<strong>al</strong> graph, line 620 willexecute; line 630 executes if you chose vertic<strong>al</strong>. The length of each bar isfound by multiplying the data v<strong>al</strong>ue being graphed by the sc<strong>al</strong>ing factorc<strong>al</strong>culated earlier. You may have wondered why the bar is drawn from 39to 39 minus its length, instead of being drawn from zero. It must becontinu<strong>al</strong>ly taken into account that 39 is the bottom of the screen and 0 isthe top, where most graphs use 0 at the bottom.650 XS = X + WS%XS represents the start of the current bar. After the bar has been drawn,this line moves the starting location to that of the next bar by adding the·bar width.A very similar routine could be written to plot the bar graph on the Hi­Res screen instead of on the Low-Res display. The limits would be changedfrom 39 to 159 or 279, depending on wh<strong>et</strong>her you plan to draw vertic<strong>al</strong>lyor horizont<strong>al</strong>ly, and you would be using the HPLOT TO command insteadof HLIN or VLIN.'This Is Where You Draw the LineSom<strong>et</strong>imes data is b<strong>et</strong>ter represented as a line ·graph. Listing 11-3 drawssuch a graph in Hi-Res and uses a shape table to put labels on the <strong>graphics</strong>screen. Enter and save the shape table by typing the following from BASIC:CALL -151300 : 0B 00 18 00 20 0 2B 00308: 36 00 41 00 4E 00 5D 00310 : 66 00 75 00 81 00 90 003 18 : 29 2D D8 24 24 JC 32 00320 : 29 2D 25 DB 0C 0C 0C 24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!