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.

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

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 * **
* not available in JS version
** works only in 2.0 compiler


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.