+ int offset = start + led * stride;
+ return Color.rgb(
+ bytes[offset + roff] & 0xff,
+ bytes[offset + goff] & 0xff,
+ bytes[offset + boff] & 0xff
+ );
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ // TODO this needs to be improved
+ /** The x position of the led from 0.0-1.0. */
+ public double xOf(int led) {
+ /* left */ if (led >= config.leds.cols * 2 + config.leds.rows) return 0;
+ /* top */ if (led >= config.leds.cols + config.leds.rows) return 1 - (double)(led - config.leds.cols - config.leds.rows) / config.leds.cols;
+ /* right */ if (led >= config.leds.cols) return 1;
+ /* bottom */ return (double)led / config.leds.cols;
+ }
+
+ /** The y position of the led from 0.0-1.0. */
+ public double yOf(int led) {
+ /* left */ if (led >= config.leds.cols * 2 + config.leds.rows) return (double)(led - config.leds.cols * 2 - config.leds.rows) / config.leds.rows;
+ /* top */ if (led >= config.leds.cols + config.leds.rows) return 0;
+ /* right */ if (led >= config.leds.cols) return 1 - (double)(led - config.leds.cols) / config.leds.rows;
+ /* bottom */ return 1;