summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-10-23 16:07:09 -0700
committerKeith Packard <keithp@keithp.com>2018-10-23 16:07:09 -0700
commitcf3e524e50a6fae2862efb404c9918b74438e9c9 (patch)
treef903b54715671ed1939d6c22ccb73c1f0fa98e42
parente9915aad4fe97cd253b88805646085c64181baef (diff)
Generate LED icons on the fly. Include SVG versions.
This builds the required LED images from source code. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--icon/Makefile.am17
-rw-r--r--icon/grayled.pngbin1528 -> 0 bytes
-rw-r--r--icon/grayon.pngbin1873 -> 0 bytes
-rw-r--r--icon/greenled.pngbin2281 -> 0 bytes
-rw-r--r--icon/greenoff.pngbin1811 -> 0 bytes
-rw-r--r--icon/led.5c189
-rw-r--r--icon/redled.pngbin2103 -> 0 bytes
-rw-r--r--icon/redoff.pngbin1694 -> 0 bytes
8 files changed, 205 insertions, 1 deletions
diff --git a/icon/Makefile.am b/icon/Makefile.am
index af238ac4..6efe3ecf 100644
--- a/icon/Makefile.am
+++ b/icon/Makefile.am
@@ -27,6 +27,17 @@ EEPROM_ICON = $(EEPROM_NAME).svg
TELEM_ICON = $(TELEM_NAME).svg
MPD_ICON = $(MPD_NAME).svg
+LED_SVG = \
+ redoff.svg \
+ greenoff.svg \
+ greenled.svg \
+ grayon.svg \
+ grayled.svg \
+ redled.svg
+LED_PNG = $(LED_SVG:.svg=.png)
+
+LED_ICONS = $(LED_SVG) $(LED_PNG)
+
# Files needed for Mac OSX icons
MAC_AM_FILES = $(shell for i in $(MAC_RES); do echo $(AM_NAME)-$$i.png; done)
@@ -109,7 +120,7 @@ java-telegps:
fat: all $(ICO_FILES) $(ICNS_FILES) $(EXE_FILES)
-all-local: $(JAVA_FILES) $(AM_XPM)
+all-local: $(JAVA_FILES) $(AM_XPM) $(LED_ICONS)
clean-local:
$(RM) $(AM_NAME)-*.png $(TG_NAME)-*.png $(MP_NAME)-*.png
@@ -117,6 +128,7 @@ clean-local:
$(RM) $(EEPROM_NAME)-*.png $(TELEM_NAME)-*.png $(MPD_NAME)-*.png
$(RM) *.build *.ico *.rc *.icns *.o *.exe $(MPD_ICON)
$(RM) altusmetrum.xpm
+ $(RM) $(LED_ICONS)
if INSTALL_SHARED_MIME_INFO
install-data-hook:
@@ -124,6 +136,9 @@ install-data-hook:
update-icon-caches $(DESTDIR)$(ICON_THEME)
endif
+$(LED_ICONS): led.5c
+ nickle led.5c $@
+
$(MPD_ICON): $(MP_ICON)
$(LN_S) $(MP_ICON) $@
diff --git a/icon/grayled.png b/icon/grayled.png
deleted file mode 100644
index bb6005c6..00000000
--- a/icon/grayled.png
+++ /dev/null
Binary files differ
diff --git a/icon/grayon.png b/icon/grayon.png
deleted file mode 100644
index c99b376e..00000000
--- a/icon/grayon.png
+++ /dev/null
Binary files differ
diff --git a/icon/greenled.png b/icon/greenled.png
deleted file mode 100644
index d7663961..00000000
--- a/icon/greenled.png
+++ /dev/null
Binary files differ
diff --git a/icon/greenoff.png b/icon/greenoff.png
deleted file mode 100644
index c3cf8491..00000000
--- a/icon/greenoff.png
+++ /dev/null
Binary files differ
diff --git a/icon/led.5c b/icon/led.5c
new file mode 100644
index 00000000..cdbcdc79
--- /dev/null
+++ b/icon/led.5c
@@ -0,0 +1,189 @@
+/*
+ * Copyright © 2018 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+/*
+ * Generate LED images for rocketview and launchcontrol
+ */
+
+autoimport Cairo;
+
+void led (cairo_t cr, real red, real green, real blue, bool on)
+{
+ translate (cr, .5, .5);
+
+ /* basic unilluminated LED */
+
+ if (true)
+ {
+ set_source_rgb (cr, red *.4, green *.4, blue *.4);
+ move_to (cr, 1, 1/2);
+ arc (cr, .5, .5, .5, 0, pi*2);
+ fill (cr);
+ }
+
+ /* Bright spot of LED illumination */
+ if (on)
+ {
+ pattern_t led = Pattern::create_radial (1/2, 1/2, 0,
+ 1/2, 1/2, .4);
+ Pattern::add_color_stop_rgba (led, 0, red, green, blue, 1);
+ Pattern::add_color_stop_rgba (led, .5, red, green, blue, .8);
+ Pattern::add_color_stop_rgba (led, 1, red, green, blue, 0);
+ set_source (cr, led);
+ move_to (cr, 1, 1/2);
+ arc (cr, .5, .5, .5, 0, pi*2);
+ fill (cr);
+ }
+
+ /* Bezel */
+ if (true)
+ {
+ pattern_t ring = Pattern::create_radial (.5, .5, .4, .5, .5, .5);
+ Pattern::add_color_stop_rgba (ring, 0, 0, 0, 0, 1);
+ Pattern::add_color_stop_rgba (ring, .5, 0, 0, 0, 1);
+ Pattern::add_color_stop_rgba (ring, 1, .5, .5, .5, 1);
+ set_source (cr, ring);
+ move_to (cr, 1, 1/2);
+ arc (cr, .5, .5, .5, 0, pi*2);
+ move_to (cr, 1, 1/2);
+ arc_negative (cr, .5, .5, .45, pi*2, 0);
+ fill (cr);
+ }
+
+ /* Specular highlight from room illumination */
+ if (true)
+ {
+ pattern_t room = Pattern::create_radial (1/3, 1/3, 0, 1/3, 1/3, 1/2);
+ Pattern::add_color_stop_rgba (room, 0, 1, 1, 1, .4);
+ Pattern::add_color_stop_rgba (room, 1, 1, 1, 1, 0);
+ set_source (cr, room);
+ move_to (cr, 1, 1/2);
+ arc (cr, .5, .5, .5, 0, pi*2);
+ fill (cr);
+ }
+
+}
+
+/*
+ * Desired LED image size in pixels
+ */
+int diameter = 12;
+
+void do_one_svg (string name, real red, real green, real blue, bool on)
+{
+ cairo_t cr = new_svg (name, diameter, diameter);
+
+ translate (cr, -width(cr)/2, -height(cr)/2);
+ scale (cr, width(cr), height(cr));
+ led (cr, red, green, blue, on);
+ destroy (cr);
+}
+
+void do_one_png (string name, real red, real green, real blue, bool on)
+{
+ cairo_t cr = new_image (diameter, diameter);
+
+ translate (cr, -width(cr)/2, -height(cr)/2);
+ scale (cr, width(cr), height(cr));
+ led (cr, red, green, blue, on);
+ write_to_png (cr, name);
+ destroy (cr);
+}
+
+void do_one(string name, real red, real green, real blue, bool on)
+{
+ do_one_png(name + ".png", red, green, blue, on);
+ do_one_svg(name + ".svg", red, green, blue, on);
+}
+
+void doit ()
+{
+ do_one ("redled", 1, 0, 0, true);
+ do_one ("redoff", 1, 0, 0, false);
+ do_one ("greenled", 0, 1, .4824, true);
+ do_one ("greenoff", 0, 1, .4824, false);
+ do_one ("grayled", .9, .9, .9, false);
+ do_one ("grayon", .9, .9, .9, true);
+}
+
+typedef struct {
+ real red, green, blue;
+ bool on;
+} stock_t;
+
+stock_t[string] stock_leds = {
+ "redled" => {
+ .red = 1,
+ .green = 0,
+ .blue = 0,
+ .on = true
+ },
+ "redoff" => {
+ .red = 1,
+ .green = 0,
+ .blue = 0,
+ .on = false
+ },
+ "greenled" => {
+ .red = 0,
+ .green = 1,
+ .blue = .4824,
+ .on = true
+ },
+ "greenoff" => {
+ .red = 0,
+ .green = 1,
+ .blue = .4824,
+ .on = false
+ },
+ "grayon" => {
+ .red = .9,
+ .green = .9,
+ .blue = .9,
+ .on = true
+ },
+ "grayled" => {
+ .red = .9,
+ .green = .9,
+ .blue = .9,
+ .on = false
+ },
+};
+
+void main ()
+{
+ for (int i = 1; i < dim(argv); i++) {
+ string name = argv[i];
+ string[] bits = String::split(name, ".");
+
+ if (dim(bits) != 2) {
+ File::fprintf(stderr, "Filename is weird: \"%s\"\n", argv[i]);
+ exit (1);
+ }
+
+ stock_t stock = stock_leds[bits[0]];
+ switch (bits[1]) {
+ case "png":
+ do_one_png(argv[i], stock.red, stock.green, stock.blue, stock.on);
+ break;
+ case "svg":
+ do_one_svg(argv[i], stock.red, stock.green, stock.blue, stock.on);
+ break;
+ }
+ }
+}
+
+if (dim(argv) > 0) {
+ main();
+}
diff --git a/icon/redled.png b/icon/redled.png
deleted file mode 100644
index 230afae0..00000000
--- a/icon/redled.png
+++ /dev/null
Binary files differ
diff --git a/icon/redoff.png b/icon/redoff.png
deleted file mode 100644
index a251402f..00000000
--- a/icon/redoff.png
+++ /dev/null
Binary files differ