💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › apple8 › Pgms › pixel… captured on 2024-07-09 at 04:45:06.

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-


A long time ago Family Computing had a bunch of little
programs showing off tricks using a 1-pixel shapetable.
You have this 1-pixel shape, and you use SCALE to
change its length. You can get that one pixel to pull
off a lot of little tricks for you.

I find it very funny that what was done way back with
this is still being done today on webpages. Nowadays
people will use a 1-pixel transparent GIF as a spacer
in tables to position objects on the screen by
stretching the height and width of that 1-pixel image.


Anyway, here are three example programs showing off how
much complexity you can do with just this simple little
one-pixel shape table.

First I have a simple example I whipped up called
"MAGIC SQUARES".... draws random overlapping grids
which makes for interesting eye candy. (For novices,
you don't have to type the REM statements)

5 REM Set up the shape table
10 POKE 232,0: POKE 233,3: DATA 1,0,4,0,4,0
20 FOR A = 768 TO 773: READ B: POKE A,B: NEXT

25 REM Reset graphics, and set scale to 159
30 TEXT : HOME : HGR : SCALE= 159
40 VTAB 21: PRINT "MAGIC SQUARES"

45 REM Draw from 0 to 159 with random stepping of
47 REM 4 to 34 steps.
50 FOR A = 0 TO 159 STEP INT ( RND (1) * 30) + 4

55 REM Draw a line down from along the top edge
60 ROT= 32: XDRAW 1 AT A,0

65 REM Draw a line to the right from the left edge
70 ROT= 16: XDRAW 1 AT 0,A
80 NEXT

85 REM Draw some more lines over the lines just drawn.
90 GOTO 50

(Press Control-C to quit) 


Here's another which draws square-spirals which
erase themselves using the same code which draws
them. (As before, you don't need to type in the
REM statements)

5 REM Set up the shape table
10  POKE 232,0: POKE 233,3: DATA 1,0,4,0,4,0
20  FOR A = 768 TO 773: READ B: POKE A,B: NEXT

25  REM Hires page 1, full screen
30  HGR: POKE - 16302,0

35  REM Get random x,y start position
40 X =  RND (1) * 279
50 Y =  RND (1) * 191

55  REM Get random scale for size of spiral
60 SC =  RND (1) * 90 + 10

65  REM Get random stepping for amount to reduce spiral size
70 RD =  RND (1) * 5 + 1

65  REM Draw the spiral twice, once to draw, once to erase
80  FOR I = 1 TO 2: R =0

85  REM Set start location for XDRAW
90  HCOLOR= 0 : HPLOT X,Y

95  REM Start at biggest size and shrink down
100  FOR A = SC TO 1 STEP -RD

103  REM Rotate 90 degrees for each XDRAW and reduce 
105  REM scale for each XDRAW. XDRAW-ing without 
107  REM coordinates starts where last XDRAW ended.
110 R = R + 16 : IF R > 63 THEN R = 0
120 ROT= R: SCALE = A: XDRAW 1
130 NEXT A,C: GOTO 40



Here's my last XDRAW example, which does very complex
"flowers". It's a set of scale and rotations which
are randomly chosen and xdrawn repeatedly. Over time
they rotate and create complex circular "flower"
shapes on the screen.

If you wait a little while, you'll discover it is
actually drawing a "regular" shape, and it will
eventually begin to overprint right from where it
started, and proceed to erase everything it had drawn
up to that point. Neat! 

Press any key to clear screen and start a new random
shape. Press Control-C to exit.

5 REM Watch for Control-C for exiting..
10  ONERR GOTO 200

15 REM Array of scale and rotations for each step
20  DIM SC%(30), RT%(30)

25 REM Shape table
30  POKE 232,0: POKE 233,3: DATA 1,0,4,0,4,0
40  FOR A = 768 TO 773: READ B: POKE A,B: NEXT
50  HOME : HGR : POKE - 16302,0

55 REM Starting point for the XDRAWs-- Make it invisible
60  HCOLOR = 0 : HPLOT RND (1) * 200+39, RND (1) * 100+45

65 REM Reset stepping variables if we're restarting
70 I = 0 : R = 0

75 REM Randomly pick number of XDRAW steps
80 CN = INT ( RND (1) * 28) + 2

85 REM Randomly pick the scale and rotation for each step
90  FOR A = 1 TO CN
100 SC%(A) = RND (1) * 10 + 4
110 RT%(A) = RND (1) * 32
120  NEXT A 

125 REM Main loop. Count up to CN, then back to zero
130 I = I + 1 : IF I > CN THEN I = 1

135 REM Rotate by the amount in RT%(I). The -16 makes the
136 REM 0-32 value in RT%(I) a rotation from -16 to +16..
140 R = R + RT%(I) - 16

143 REM Adding or subtracting from R can make it exceed
145 REM the 0-63 range. These lines "wrap the value" if
147 REM it goes too far one way or the other.
150 IF R > 63 THEN R = R - 64
160 IF R < 0 THEN R = R + 64

165 REM Scale by stored random amount, rotate by new
167 REM random amount (+/- 90 degrees) and XDRAW segment
170 SCALE= SC%(I) : ROT= R : XDRAW 1

175 REM Watch for any keypress. If none, continue drawing.
180 IF PEEK (-16368) < 128 THEN 130

185 REM IF there is a keypress, start over.
190 GOTO 50

195 REM If control-C pressed, ONERR jumps to here to exit.
200 TEXT : END

(For easier debugging, remove line 10 until it is
bug-free. Line 10 looks for any error and jumps to
200 if it sees one. The only 'error' if it is working
right will be caused when you press Control-C.)

-Mr. Boffo

Email: mister_boffo@hotmail.com



On Thu, 06 Jan 2000 11:04:52 GMT, mister_boffo@hotmail.com (Mr. Boffo)
wrote:

Darn, I found a bug while reading it over again.
In program #2, change line 130...

>130 NEXT A,C: GOTO 40

Should be:

130 NEXT A,I: GOTO 40


-Mr. Boffo

Email: mister_boffo@hotmail.com