**String Art**

Craig Maiman

Spring Valley, NY

If you always wanted a program which generates beautiful mathematical patterns, now you have it. This program serves very well to impress friends (and yourself!) with the graphics capabilities of the Atari 400/800.

The program actually generates two lissajous figures that are TWISTed relative to each other, it then draws lines between them. The variables that determine the shape of the lissajous are FREQUENCY RATIO and PHASE. Since a lissajous pattern is generated by two signals perpendicular to each other, as on an oscilloscope, we can specify their frequency ratio to obtain many different figures. Changing the phase makes the pattern seem to rotate in 3-D space. An example would be a circle which has a frequency ratio of one-to-one and a phase of 0 degrees. If you now change the phase to 45 degrees it will look like a tilted ellipse. Another variable which can be controlled is DISPLACEMENT: this variable determines the vertical separation of the two lissajous patterns. It can be varied between 0 and 95.

Here are some numbers to generate nice patterns:

FREQUENCY RATIO: 1, 1PHASE: 40TWIST: 135DISPLACEMENT: 0FREQUENCY RATIO: 2, 1PHASE: 0TWIST: 60DISPLACEMENT: 0FREQUENCY RATIO: 1, 2PHASE: 45TWIST: 120DISPLACEMENT: 70

**Hints**

- Good numbers for the FREQUENCY RATIO are various combinations of 1,2, and 3. Higher numbers tend to make messy pictures.
- For PHASE, 0 and 90 are good numbers, but try numbers in between also.
- The TWIST can be varied from—180 to 180. Try them all if you want.
- DISPLACEMENT can vary between 0 and 95. When you get near 90 all the pictures start looking the same. For starters, I would recommend using 0 then try 20, 30, etc.

Now to reveal the secrets of the program:

Lines Description20-40 Screen initialization (Put String… in inverse video)50-80 Prompts for input (Put these in inverse video)90 Tests for illegal displacement130-140 Initializes screen for GRAPHICS 8160-170 generates first lissajous180-190 generates second lissajous200 plots and connects the 2 lissajous210-220 tests for key touch

10 REM STRING ART ! BY CRAIG MATMAN, JULY, 1981 20 GRAPHICS 0 = SETCOLOR 1,3,10: SETCOLOR 2,3,0 30 SETCOLOR 4,6,0 = H = 95 : POKE 752, 1 40 ?" | STRING ART PROGRAM |" 50 ? :? :? " | INPUT FREQUENCY RATIO |" ;: INPUT A, B 60 ? :? :? " | INPUT PHASE |" ; : INPUT PH 70 ? :? :? "| INPUT TWIST I" ; : INPUT TW 80 ? :? :? " | INPUT DISPLACEMENT |" ; : | INPUT DI 90 IF DI> 95 THEN 80 100 ? :? :? "| WHEN PICTURE IS DONE HIT |" 110 ? " | ANY KEY TO CONTINUE |" 120 FOR D = 0 T0 TO 680 : NEXT D 130 DEG : GRAPHICS 24 : SETCOLOR 1,3,10 140 SETCOLOR 2, 3, 0 : SETCOLOR 4, 6, 0 : COLOR 1 150 FOR ANG = 0 TO 360 STEP 5 168 X1 = H * SIN (A * ANG) + 159 170 Y1 = (H - DI) * COS (B * ANG + PH) + 96 - DI 180 X2 = H * SIN (A *(ANG + TW)) + 159 190 Y2 = (H -DI)* COS (B*(ANG + PH + TW)) + 96 + D1 200 PLOT X1, Y1 : DRAWTO X2, Y2 : NEXT ANG 210 IF PEEK (764) <> 255 THEN POKE 764, 255 : GOTO 20 220 GOTO 210