Modulated line

Modulated line


It is a drawing generator based on the movement of a hypothetical pencil that advances following an oscillating direction with cyclic variations of the oscillation speed.

Core algorithm

In a two-dimensional space that continues on opposite edges (as if it were the surface of a torus), the position of the initial point, the direction of the displacement and the initial speed of the oscillations are randomly obtained. The variations can also be so large that the direction is blocked until the value returns to be less than 360°.

Despite appearances, randomness is only used at the start, while the rest is determined by the subsequent addition and subtraction of angles.

Code biography

Original version programmed in MSX-BASIC on a Philips VG-8235 MSX2 home computer.
Discovery of the WebMSX emulator and usage with the code transcribed from a thermal paper printout from the late 1980s.
Version recoded in Processing with the possibility of randomly setting two new parameters: the amplitude of the oscillations and the cyclic variation of the oscillation speed.
Third recoding to make the artwork executable on the web through the Processing.js library.
Last readjustment of the code to the p5.js library with random reset of all startup parameters through a simple mouse click.

First version

In the original version of 1987, the pixels were rectangular because the graphics mode with the highest resolution (512x212 pixels) was obtained by interlacing two screens of 256x212 pixels. The violet variations in the grays were due to the impossibility of obtaining 16 neutral shades of gray with only 8 levels for each of the primary colors (red, green and blue).

To get the Cartesian coordinates of the displacements more quickly, the increment and decrement values were calculated and stored in advance. The operation was displayed through a succession of points placed along a circumference.

WebMSX emulator set to run the first version programmed in MSX-BASIC. The speed is the original one, but you can accelerate it by pressing Shift+Alt+⇧ several times.

Processing version

Over the years, the code has been converted to Processing making random, always and only at startup, also the amplitude of oscillations and an additional parameter of cyclic variation of the oscillation speed.

P5.js version

The code was also converted to p5.js to make it possible to execute on the web.

The p5.js version with the possibility to randomly reset all startup parameters with a mouse click.