Skip to content

Cloning After Dark in APL

Vector 9:1, page 131

graphics programming techniques

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 131

Screen savers, programs that do funny things to your screen after prolonged inactivity, are all the rage with Windows users. One of the most popular programs, After Dark, has a module which draws a number of lines on your screen to form a very pleasing pattern.

It can be reproduced by the inevitable APL one-liner which I offer below:

PLOT 1○○(.5,[⎕IO+.1]2×(⍳LINES)÷LINES)+.×1-⎕IO-?⍉2 2 2⍴4,COMPLEXITY

LINES is the number of lines required, COMPLEXITY is a positive integer (try 4, more than about 6 makes a bit of a mess) and PLOT is a function that takes an n×2×2 matrix and draws a line between ARG[i;1;] and ARG[i;2;] for all i (APL*PLUS’s ⎕GLINE is such a function).

A pattern of several hundred straight lines whose ends trace curves, enveloping a twisted, sail-like surface inside a roughly circular outline