Light Pattern

From Esolang
Jump to navigation Jump to search

In Light Pattern, created by User:Rottytooth, a series of photos constitute source code. Changes in exposure and dominant color from one image to the next determine commands – the language has no regard for the content of the images apart from these attributes. Photos sit in a single directory and are read in alphabetical order. Light Pattern programs can be hidden in family photographs or any collection of images, given they are arranged in the right order.


Programming languages are denotative, lacking much of the nuance and bodily gesture of human expression – it is a negotiation between human thinking and computer logic. The camera, likewise, has no regard for connotation – it is an apparatus with no understanding of content, as pointed out by conceptual photographic work such as John Hilliard's Camera Recording Its Own Condition (1971). Light Pattern requires a programmer to take photos with technical considerations in mind. The content of the photos is irrelevant, inscrutable to the compiler. The pattern of color and exposure in the resulting photos make up the source code for a Light Pattern program.

Original Hello, World

From "Hello, World!" sequence From "Hello, World!" sequence From "Hello, World!" sequence

To create a Hello, World for the beta version of Light Pattern, I constructed a machine to take photos in the correct order, and asked classmates to interact with it. When a camera is pointed in someone's direction, they tend to either perform for it, or sit uncomfortably. One edit of the photos can be seen here(dead link) with a mock-up of the resulting program. There is also a picture of the apparatus(dead link) itself.

Please note that this program no longer works in Light Pattern, the language was redesigned to be easier to work with. A working Hello, World will be provided below.

Language Overview

Commands are determined by sets of three-digit ternary numbers. Each number is a delta from one photo to the next (read alphabetically), each digit representing changes in one of three attributes: Color, Aperture, and Shutter Speed. If the value stays the same for an attribute (such as Color), it is always recorded as a 1, which always indicates no change.

  • If the shutter speed becomes longer (slower), that is a 2, if the speed increases, it is a 0.
  • If the aperture becomes larger (smaller f-stop number), that is a 2, the other way indicates a 0.

In other words, if the shutter or aperture change to let in more light, the number is 2.

  • Color cycles Red -> Green -> Blue (wrapping around back to Red). If it progresses in this cycle, it's a 2, if it goes a step backward, it is 0.

Light Pattern works with JPEGs only, as aperture and shutter are pulled from the EXIF data. Color is the dominant color of the photo, determined by counting RGB values pixel-by-pixel.

Example of how deltas are determined

Four photos:

1/2, 6.7, Red
1, 8, Red
1, 8, Red
1/2, 9.5, Red

This would translate to:

201 : shutter speed of 2 (slower), aperture smaller (0), Color the same (1).
111 : everything stays the same (all 1s).
001 : shutter speed of 0 (faster), aperture smaller (0), Color the same (1).

This program declares a variable called 111 as an int.



Value Command Notes
200 Let followed by variable name, then by expression
201 Declare followed by variable name, then by type
202 While followed by expression, then by commands
210 End While  
211 If followed by expression, then by commands
212 Else  
220 End If
221 Print
222 Reset Indicates that the following photo should be ignored. Used when shutter speeds get too fast or apertures too large.
001 Fork Fork process


Used only in declarations.

Value Type
001 Int
010 Char
011 Double
012 String


Value Expression Notes
100 Variable followed by variable name
101 Int (+) followed by length (in deltas), then by value
102 Int (-) negative value – followed by length (in deltas), then by value
110 Char followed by length (in deltas), then by value
111 Double (+) followed by pre-decimal length, post-decimal length, then pre-decimal value, then post-decimal value
112 Double (-) negative value – followed by pre-decimal length, post-decimal length, then pre-decimal value, then post-decimal value
120 Begin String followed by lengths and char values for each character
000 End String  
020 Two-Code Expression Indicator followed by another code from the Two-Code Expression list

Two-Code Expressions

These are expressions that require two codes instead of one. The first code is the two-code expression indicator (020). These are the second codes:

Value Expression
000 ==
001 >
002 <
010 NOT
011 AND
012 OR
020 (
021 )
022 +
100 -
101 *
102 /
101 %

Building Programs

Light Pattern programs can be complicated to create, but the compiler provides tools to make it easier. Here's a suggested method:

1. List the numeric codes for the program you want to write, in a .lpc file, with one three-digit code per line (comments can follow, after // ). Run the compiler with a /g flag on that file. A .lp file is created, translating the codes into suggested exposure / color combinations. It assumes a camera that can shoot in half-steps, so some adjustments may be needed (keep in mind it is all delta-based, so the exact numbers don't matter as long as they're consistent).

If any "out of range" errors are reported, check the line number, and find a good place just before then to put a "222" reset command (hopefully this will be automated in future versions). This should also be used if it suggests a shutter speed that's faster than the camera you're using is capable of, or a lens with a smaller max aperture, etc.

2. Run the compiler on the .lp file with a /n flag. A /c flag can be added as well to produce a C# file rather than an executable.

3. These two steps should be repeated until the program functionality is perfect. At that point, take the list of exposures in the .lp file and shoot the images as listed. This produces the final Light Pattern program, which can be compiled with the directory name.

During compilation, the compiler writes out the color and exposure info – if anything's off, one thing to check is if the compiler's interpretation of the color is different than what you expected.


The beta of Light Pattern did not use aperture, only shutter speed, which required longer sequences of images for each command.

External resources