From d4c3fcd1e1e692b7dfdfbaa95de5d10ef7e79c59 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 3 Jun 2016 09:01:38 -0600 Subject: [PATCH] Color suitability based on gcolor_legible_over --- appinfo.json | 2 +- src/main.c | 18 +++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/appinfo.json b/appinfo.json index e052257..c4d1cb6 100644 --- a/appinfo.json +++ b/appinfo.json @@ -36,7 +36,7 @@ "chalk" ], "uuid": "f00033b1-2e6c-490c-a650-99d9399b2163", - "versionLabel": "1.4", + "versionLabel": "1.5", "watchapp": { "watchface": true } diff --git a/src/main.c b/src/main.c index d5ffc7b..7345800 100644 --- a/src/main.c +++ b/src/main.c @@ -25,23 +25,11 @@ GPoint center; bool bt_connected; -static int32_t luminosity(GColor c) { - int r = (c.argb & 0b110000) >> 4; - int g = (c.argb & 0b001100) >> 2; - int b = (c.argb & 0b000011) >> 0; - - return (2126 * r) + (7152 * g) + (722 * b); -} - static bool visible_against(GColor a, GColor b) { - int32_t la = luminosity(a); - int32_t lb = luminosity(b); + GColor na = gcolor_legible_over(a); + GColor nb = gcolor_legible_over(b); - if ((la - lb > 15000) || (lb - la > 15000)) { - return true; - } else { - return false; - } + return (! gcolor_equal(na, nb)); } static GPoint point_of_polar(int32_t theta, int r) {