Blinkenlights Library for Processing
This
Processing library is designed to export sketches to the
Blinkenlights BML file format. If you'd like to convert a load images to BML, please check out Dan Fraser's
converter.
Updates
- v1.3: added getVersion() to ensure that you're using the latest version :^)
- v1.2: added the showPreview(boolean show) method to BMLWriter. Unless you set this to true, you will not see a pixelated preview of your sketch. This is because enable the preview can cause the bad effects when you export. When you export your sketch, turn off the preview and the grid.
- v1.1: The library has been modified to use Dan Fraser's PacketSender library, which allows you to write network packets to a BlinkenServer. The BML writing class has been renamed from Blinkenlights to BMLWriter.
- The library can now overlay a grid and rectangles representing the windows of the Toronto City Hall by calling bl.showGrid(true). The grid will only appear if running with the native Stereoscope virtual matrix: 96x32.
Installation Instructions
- Download the library and documentation from GitHub.
- Unzip it and open the blinkenlights_processing folder.
- Move the Blinkenlights folder into your sketchbook folder (usually ~/Documents/Processing on a Mac or My Documents/processing on Windows).
Usage Instructions
- Start Processing.
- From the Sketch menu, choose Import Library -> Blinkenlights.
- In your setup() method, create a new Blinkenlights instance:
int frameDuration = 41; // 24 fps
BMLWriter bl = new BMLWriter(this, frameDuration);
bl.setCountX(5);
bl.setCountY(10);
bl.setAuthor("Robin Senior");
bl.setTitle("My First Sketch");
bl.setEmail("senior@gmail.com");
bl.setURL("www.robinsenior.com");
Doing this will cause your sketch to look pixelated when you run it. If you are happy with how it looks, start writing it to a BML file by putting this in your setup() method:
bl.startWriting("circle.bml");
If you would like to send your sketch directly to a BlinkenServer, first create a PacketSender and then pass it to the BMLWriter constructor:
PacketSender mySender = new PacketSender(this,"127.0.0.1",2323);
BMLWriter bl = new BMLWriter(this, 41, mySender);
ATTENTION: When exporting to file or across the network, make sure that the grid and the preview are turned off, or it make cause the image to be exported with visual artifacts.
Here is a sample application, view it in action
here:
import processing.blinkenlights.*;
int x = 0;
void setup()
{
BMLWriter bl = new BMLWriter(this, 41);
bl.setAuthor("Robin Senior");
bl.setTitle("Crappy Circle");
bl.setEmail("senior@gmail.com");
bl.setURL("www.robinsenior.com");
size(960, 320);
frameRate(30);
colorMode(RGB,255);
smooth();
noStroke();
bl.startWriting("circle.bml");
}
void draw()
{
background(0);
fill(255);
ellipse(x,height/2,150,150);
ellipse(width-x,height/2,150,150);
x += 5;
if (x>width)
x=0;
}
Gallery
Several of these examples are adapted from sketches originally made by
Daniel Shiffman.
Notes
- This library may not work correctly if used from Eclipse. For some reason when you quit your sketch, the library isn't notified. This may result in malformed BML files, which can be easily fixed by hand.
- To avoid missing regions along the right and bottom borders of your sketch, make your sketch's width and height are a multiple of your x count and y count, respectively.
- This code is licensed under the GPL. Please contact Robin Senior at senior@gmail.com if you would like to contribute any updates.