Canvas2DMX is a Processing library for mapping pixels from your sketch directly to DMX fixtures.
It lets you define LED mappings (strips, grids, rings, corners), apply color correction, and send data to any DMX backend (ENTTEC, SP201E, DMX4Artists, or your own).
Github Pages link: Canvas2DMX.
Inspired by FadeCandy and Open Pixel Control (OPC) by Micah Elizabeth Scott.
- Real-time color sampling from Processing canvas
- Flexible LED mapping: strips, rings, grids, single points, square corners
- Custom DMX channel patterns (e.g.
"rgb"
,"drgb"
,"drgbsc"
) - Default channel values for dimmer, strobe, color wheel, etc.
- Gamma correction and color temperature adjustment
- Built-in visualization (color bars, LED markers)
- Agnostic DMX output: works with DMX4Artists, ENTTEC, SP201E, or any controller via a simple callback
- Ships with examples from beginner to interactive
Click the thumbnail above to watch Canvas2DMX in action on YouTube.
-
Download the library release and unzip into your
Processing/libraries/
folder.
(After publishing, youβll be able to install via Sketch β Import Library β Add Libraryβ¦) -
Restart Processing. The library will appear under Sketch β Import Library β Canvas2DMX.
-
Explore the included examples via
File β Examples β Contributed Libraries β Canvas2DMX.
import io.studiojordanshaw.canvas2dmx.*;
import com.jaysonh.dmx4artists.*;
Canvas2DMX c2d;
DMXControl dmx;
void setup() {
size(400, 200);
pixelDensity(1); // important for accurate color sampling on HiDPI screens
c2d = new Canvas2DMX(this);
c2d.mapLedStrip(0, 8, width/2f, height/2f, 40, 0, false);
c2d.setChannelPattern("drgb"); // Dimmer + RGB
c2d.setDefaultValue('d', 255); // Dimmer full
c2d.setStartAt(1); // Start at DMX channel 1
try {
dmx = new DMXControl(0, 512); // connect to first available DMX device
} catch (Exception e) {
println("DMX init failed: " + e.getMessage());
dmx = null;
}
}
void draw() {
background(0);
ellipse(mouseX, mouseY, 100, 100);
int[] colors = c2d.getLedColors();
c2d.visualize(colors);
c2d.showLedLocations();
if (dmx != null) {
// agnostic sender: DMX4Artists, ENTTEC, or your own backend
c2d.sendToDmx((ch, val) -> dmx.sendValue(ch, val));
}
}
The library ships with 3 examples, found in the Processing IDE under File β Examples β Contributed Libraries β Canvas2DMX.
- Basics.pde β Map one LED, sample from canvas, send to DMX
- StripMapping.pde β Map a strip of LEDs and animate a gradient
- InteractiveDemo.pde β Drag a circle, explore fixture patterns, test DMX values with keyboard controls
Each example will run without hardware (console shows mock DMX output).
When a DMX controller is connected, sendToDmx(...)
sends live data.
c2d.setLed(0, x, y);
c2d.mapLedStrip(0, 10, 200, 200, 20, radians(45), false);
c2d.mapLedRing(0, 12, 200, 200, 50, 0);
c2d.mapLedGrid(0, 8, 4, 200, 200, 20, 25, 0, true, false);
c2d.mapSquareCorners(0, 200, 200, 100, 45);
Configure fixtures with channel layouts:
c2d.setChannelPattern("rgb"); // RGB only
c2d.setChannelPattern("rgbw"); // RGB + White
c2d.setChannelPattern("drgb"); // Dimmer + RGB
c2d.setChannelPattern("drgbsc"); // Dimmer + RGB + Strobe + Color wheel
c2d.setDefaultValue('d', 255); // Default dimmer value
c2d.setDefaultValue('s', 0); // Strobe off
setChannelPattern(String pattern)
β define fixture layoutsetStartAt(int startAt)
β starting DMX channelsetDefaultValue(char channel, int value)
β default values for non-RGB channelsgetLedColors()
β sample pixels and apply correctionssendToDmx(BiConsumer<Integer,Integer>)
β send DMX via any backendbuildDmxFrame(int universeSize)
β generate full DMX frame array
setResponse(float gamma)
β gamma correction (1.0 = linear, 2.2 typical)setTemperature(float t)
β adjust color temperature (-1 = warm, 1 = cool)setCustomCurve(float[] curve)
β custom correction curve
showLedLocations()
β draw LED markers on canvasvisualize(int[] colors)
β draw sampled LED colorssetShowLocations(boolean enabled)
β toggle marker drawing
You can save the current response/temperature/curve settings to a file and reload them later.
This is useful for keeping fixture profiles consistent across sketches.
// Save current settings to a file
c2d.saveSettings("mySettings.txt");
// Later, reload them
c2d.loadSettings("mySettings.txt");
Instead of a simple gamma correction, you can define your own brightness curve.
The curve is an array of values between 0.0
and 1.0
that remap input brightness β output brightness.
This lets you calibrate your LEDs more precisely than with setResponse()
.
// Example: nonlinear custom brightness curve
float[] customCurve = {
0.0, // off
0.05, // very dim
0.2,
0.5,
0.8,
1.0 // full brightness
};
c2d.setCustomCurve(customCurve);
Colors wrong or always white
- Ensure
pixelDensity(1)
insetup()
- Use
'l'
key in examples to check LED positions - Verify your fixtureβs DMX channel pattern
DMX not connecting
-
Try alternate init methods:
new DMXControl(0, 256); // device index new DMXControl("SERIAL_NUMBER", 256); // serial new DMXControl("/dev/tty.usbserial-XXX", 256); // port path
Performance
- Reduce number of LEDs
- Use
frameRate(30)
- Disable debug printing
- Visualization of DMX channel mapping
- Logging DMX output to file
- Support for RGBW / RGBA fixtures
- Real-time controls (sliders, OSC, MIDI)
- FadeCandy by Micah Elizabeth Scott
- Open Pixel Control
Original OPC Credit: Micah Elizabeth Scott, 2013. Released into the public domain.
MIT License Β© 2025 Studio Jordan Shaw