Afterimage Test
- Type
- Graphics
- Category
- Optical illusion demonstration
- Author
- Nick Koziupa
- Published in
- Antic, July 1987 (Vol. 6, No. 3)
- Year
- 1987
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, 16K RAM, Atari BASIC; a colour monitor or TV
About the program
Nick Koziupa's biology teacher once showed his class how a bright image, such as a flashbulb's glare, can be "burned" into the retina, so that you still see it after it has gone. Koziupa, a high-school sophomore in Hamilton Township, New Jersey, who had been programming his Atari for three years, turned the lesson into a program. You choose a colour and a shape. The screen turns a dull white and the shape appears in the middle. After about 15 seconds it vanishes. Keep staring at the same spot and you should see the shape again in the complementary colour: a green ghost after a red square, for example.
Typing it in
Inverse title text appears in lines 130, 270 and 1010–1190 ({inv}…{/inv}: press the Atari key before and after). {CLEAR} inside the quotes is typed as ESC then SHIFT-CLEAR. The circle is drawn from 96 pairs of coordinates in DATA lines 500–590, so check those carefully. A wrong number just puts a stray dot on the circle's outline, or (from point 56 onwards) makes the fill go wrong.
How to use it
Answer Y or N to the instructions question (with Y, press START after reading them). Then press 1–6 for red, blue, yellow, green, purple or orange, and 1–4 for circle, square, triangle or cross. Fix your eyes on the middle of the shape and try not to blink. When it disappears, keep looking at the blank space. A few seconds later the program returns to the colour menu.
The effect is stronger in a dim room, and with the brightness turned down a little.
How it works
The trick is that the shape is drawn invisibly. Every test starts in full-screen GRAPHICS 7 (7+16) with the background (712), playfield 2 (710) and playfield 0 (708) all set to the same grey-white, colour value 10. The shape is plotted with COLOR 1, which uses register 708, so it's the same colour as everything around it while it's being drawn. Then a single SETCOLOR 0,COL,LUM makes the finished shape appear all at once. After a delay loop, POKE 708,10 makes it disappear just as suddenly, without erasing a pixel. A sudden appearance and disappearance is exactly what the experiment needs. Watching it being drawn line by line would spoil the effect.
Two different fill methods are used:
- Circle and square use the operating system's fill command,
XIO 18,#6,0,0,"S:". Location 765 (FILDAT) holds the colour to fill with. You plot the left-hand edge point by point, and each XIO call fills to the right until it meets a lit pixel. For the circle, the first 56 DATA points draw the right half of the outline and the rest fill from the left half. - Triangle and cross are filled by drawing lots of lines: a fan of
DRAWTOs from the apex for the triangle, and two blocks of horizontal and vertical lines for the cross.
Keys are read with GET #1 from the keyboard device, opened in line 1040, so you never need to press RETURN.
Variations to try
- Lengthen the staring time (the 3500 in the
FOR DEloops) and see whether the ghost gets stronger. - Add your own colours: the first number in
SETCOLOR 0,COL,LUMis the hue (0–15) and the second is the brightness (even numbers 0–14). - Try a black background (
POKE 710,0:POKE 712,0, and 0 in the matchingPOKE 708s) to see how the afterimage changes.
Listing
70 REM AFTERIMAGE TEST
80 REM BY NICK KOZIUPA
90 REM (c) 1987, ANTIC PUBLISHING
100 GOSUB 1000
110 REM COLOR CHOICE
120 ? "{CLEAR}":? :POKE 752,1
130 ? " {inv}Afterimage Test{/inv}"
140 ? :? "Choose the color of the object to focus on:"
150 ? :? "1) Red":? "2) Blue":? "3) Yellow":? "4) Green":? "5) Purple"
160 ? "6) Orange"
170 GET #1,A
180 IF A=49 THEN COL=4:LUM=2:GOTO 250
190 IF A=50 THEN COL=8:LUM=2:GOTO 250
200 IF A=51 THEN COL=1:LUM=8:GOTO 250
210 IF A=52 THEN COL=12:LUM=2:GOTO 250
220 IF A=53 THEN COL=5:LUM=2:GOTO 250
230 IF A=54 THEN COL=2:LUM=6:GOTO 250
240 GOTO 170
250 REM SHAPE CHOICE
260 ? "{CLEAR}":?
270 ? " {inv}Afterimage Test{/inv}"
280 ? :? "Choose the shape of the object to focus on:"
290 ? :? "1) Circle":? "2) Square":? "3) Triangle":? "4) Cross"
300 GET #1,A
310 IF A=49 THEN SHAPE=1:GOTO 360
320 IF A=50 THEN SHAPE=2:GOTO 360
330 IF A=51 THEN SHAPE=3:GOTO 360
340 IF A=52 THEN SHAPE=4:GOTO 360
350 GOTO 300
360 ON SHAPE GOSUB 380,600,690,760
370 GOTO 110
380 REM CIRCLE TEST
390 GRAPHICS 7+16:POKE 710,10:POKE 712,10:COLOR 1:POKE 708,10
400 RESTORE 500
410 POKE 765,1
420 FOR N=0 TO 95
430 READ X,Y:PLOT X,Y
440 IF N>55 THEN XIO 18,#6,0,0,"S:"
450 NEXT N
460 SETCOLOR 0,COL,LUM
470 FOR DE=1 TO 3500:NEXT DE
480 POKE 708,10
490 FOR DE=1 TO 2500:NEXT DE:RETURN
500 DATA 77,33,78,33,79,33,80,33,81,33,82,33,83,33,84,34,85,34,86,34
510 DATA 87,35,88,35,89,36,90,37,91,38,92,39,92,40,93,40,93,41,93,42
520 DATA 94,42,94,43,94,44,94,45,95,45,95,46,95,47,95,48,95,49,95,50
530 DATA 95,51,94,51,94,52,94,53,94,54,93,54,93,55,93,56,92,56,92,57
540 DATA 91,58,90,59,89,60,88,61,87,61,86,62,85,62,84,62,83,63,82,63
550 DATA 81,63,80,63,79,63,78,63,77,63,76,62,75,62,74,62,73,61,72,61
560 DATA 71,60,70,59,69,58,68,57,68,56,67,56,67,55,67,54,66,54,66,53
570 DATA 66,52,66,51,65,51,65,50,65,49,65,48,65,47,65,46,65,45,66,45
580 DATA 66,44,66,43,66,42,67,42,67,41,67,40,68,40,68,39,69,38,70,37
590 DATA 71,36,72,35,73,35,74,34,75,34,76,34
600 REM SQUARE TEST
610 GRAPHICS 7+16:POKE 710,10:POKE 712,10:COLOR 1:POKE 708,10
620 PLOT 64,35:DRAWTO 96,35:DRAWTO 96,62:DRAWTO 64,62
630 POKE 765,1
640 FOR X=62 TO 35 STEP -1:PLOT 64,X:XIO 18,#6,0,0,"S:":NEXT X
650 SETCOLOR 0,COL,LUM
660 FOR DE=1 TO 3500:NEXT DE
670 POKE 708,10
680 FOR DE=1 TO 2500:NEXT DE:RETURN
690 REM TRIANGLE TEST
700 GRAPHICS 7+16:POKE 710,10:POKE 712,10:COLOR 1:POKE 708,10
710 FOR X=60 TO 100:PLOT 80,32:DRAWTO X,64:NEXT X
720 SETCOLOR 0,COL,LUM
730 FOR DE=1 TO 3500:NEXT DE
740 POKE 708,10
750 FOR DE=1 TO 2500:NEXT DE:RETURN
760 REM CROSS TEST
770 GRAPHICS 7+16:POKE 710,10:POKE 712,10:COLOR 1:POKE 708,10
780 FOR X=75 TO 85:PLOT X,35:DRAWTO X,62:NEXT X
790 FOR X=44 TO 53:PLOT 64,X:DRAWTO 96,X:NEXT X
800 SETCOLOR 0,COL,LUM
810 FOR DE=1 TO 3500:NEXT DE
820 POKE 708,10
830 FOR DE=1 TO 2500:NEXT DE:RETURN
1000 GRAPHICS 0:POKE 752,1:POKE 82,0:? "{CLEAR}"
1010 ? :? :? " {inv} Afterimage Test {/inv} "
1015 ? :? " by Nick Koziupa"
1020 FOR DE=1 TO 350:NEXT DE
1040 CLOSE #1:OPEN #1,4,0,"K:"
1045 ? "{CLEAR}":? :? " {inv}Afterimage Test{/inv}"
1050 ? :? "Do you need instructions (Y/N)?";
1060 GET #1,A
1070 IF A=89 THEN 1100
1080 IF A=78 THEN RETURN
1090 GOTO 1060
1100 REM INSTRUCTIONS
1110 ? "{CLEAR}{inv} Afterimage Test by Nick Koziupa {/inv}"
1120 ? :? " This program demonstrates afterimages":? "(how your eyes percieve an image ";
1130 ? "after it has disappeared.)":? :? " After selecting an object to view,"
1140 ? "the screen will change to a dull shade":? "of white. Within seconds, the shape"
1150 ? "will appear at the center of the":? "screen. Fix your eyes upon the center"
1160 ? "of the object. After about 15":? "seconds, the object will disappear."
1170 ? "Continue to look at the area where the":? "shape had been. If the experiment was"
1180 ? "successful, the image will still be":? "visible, but now in the opposite"
1190 ? "color.":? :? "{inv} Press [START] to begin {/inv}"
1200 IF PEEK(53279)<>6 THEN 1200
1210 RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: AFTIMAGE.BAS.
Credits
- Program listing: Afterimage Test — program listing (Antic, July 1987 (Vol. 6, No. 3)) — Nick Koziupa
- Picture: The circle test with option 1, red (SETCOLOR 0,4,2). Stare at it until it disappears. — Nick Koziupa (program); screenshot by the site
- Antic, July 1987 - Vol. 6 No. 3 — article: Afterimage Test, graphics demo by Nick Koziupa — Nick Koziupa, 1987
- Antic Software Archive — July 1987 - Vol. 6 No. 3 disk: AFTIMAGE.BAS — AtariMagazines.com (Kevin Savetz), 1987
