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.

128 APPLE II COMPUTER GRAPHICS71¥l PRINT "J F M A M J J A S 0 N D J F MA E A P A U U U E C 0 E A E AN B R R Y N L G P T V C N B R";72¥l VTAB (2¥l)This section labels the horizont<strong>al</strong> axis by a m<strong>et</strong>hod which makes up insimplicity what it lacks in style. Lines 650-69(/) draw the little tic-mark onthe axis, and line 71(/) prints the labels in the four lines of text at the bottomof the Hi-Res page. Line 71 (/) was actu<strong>al</strong>ly designed after the graph hadbeen plotted by using the "Escape Mode" editing features of the Apple. Ifyou use HGR2 or leave Hi-Res space below the graph, you could label thehorizont<strong>al</strong> axis in the same way we labeled the vertic<strong>al</strong>.75¥l REM * PLOT DATA POINTS *78¥l HCOLOR = 779¥l HPLOT 24, 16¥l-DP(¥l) * SCL8¥l¥l FOR I = 1 TO NP%-181¥l X = 24 + I * SP%82¥l Y = DP (I) * SCL83¥l IF X > 279 THEN PRINT CHR$ (7) ;"CHART TOO WIDE" : GOTO 86¥l : REM (END )84¥l HPLOT TO X ,16¥l-Y85¥l NEXT IThe heart of the routine is in this short section. Line 79(/) plots the fi rst pointto establish an initi<strong>al</strong> point for the line, then line 84(/) plots the rest of thepoints. The X-coordinate is the left side of the frame (24) plus the offs<strong>et</strong> foreach point. DP(4) will be plotted at 24 + 4 * 18, or 96.The Y-coord inate is c<strong>al</strong>culated by multiplying the data v<strong>al</strong>ue by thesc<strong>al</strong>ing factor. It should seem curious that the Y-coordinate is not plotteddirectly, but is subtracted from 160. Remember that the Apple thinks (/) is atthe top of the screen and 16(/) at the bottom, so the quick little subtractionturns things around to put (/) on the bottom where you usu<strong>al</strong>ly want it.The 15 data points are stored in DP((/)) through DP(14). This is why theFOR/NEXT loop established in line 8(/)(/) only goes to one less than thenumber of points (NP%-1).Function<strong>al</strong> PlottingMany times a graph may be drawn from a function or formula instead ofdata points. Listing 11-4 is a short example which graphs a couple offormu las. Try it out!1¥l REM FUNCTION DEMO2¥l REM3¥l DEF FN A(X) .¥l2 * x /\ 2 + 54¥l DEF FN B(X) . ¥l¥ll * x /\ 3

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

Saved successfully!

Ooh no, something went wrong!