diff layer/ColourDatabase.h @ 1578:57a4ee52ad69 background-mode

Make nearby-colour matching a bit more sophisticated, with slightly better algorithm (we think?) and ability to insist on dark/light background
author Chris Cannam
date Fri, 24 Jan 2020 12:40:07 +0000
parents ad86aa712d11
children
line wrap: on
line diff
--- a/layer/ColourDatabase.h	Thu Jan 23 15:43:51 2020 +0000
+++ b/layer/ColourDatabase.h	Fri Jan 24 12:40:07 2020 +0000
@@ -71,13 +71,20 @@
      */
     bool haveColour(QColor c) const;
 
+    enum WithBackgroundMode {
+        WithAnyBackground,
+        WithDarkBackground,
+        WithLightBackground
+    };
+    
     /**
      * Return the index of the colour in the database that is closest
-     * to the given one, by some simplistic measure (Manhattan
-     * distance in RGB space). This always returns some valid index,
-     * unless the database is empty, in which case it returns -1.
+     * to the given one, by some simple measure. This always returns
+     * some valid index, unless the database is empty, in which case
+     * it returns -1.
      */
-    int getNearbyColourIndex(QColor c) const;
+    int getNearbyColourIndex(QColor c,
+                             WithBackgroundMode mode = WithAnyBackground) const;
 
     /**
      * Add a colour to the database, with the associated name. Return
@@ -110,9 +117,9 @@
 
     /**
      * Return a colour that contrasts with the one at index c,
-     * according to some simplistic algorithm. The returned colour is
-     * not necessarily in the database; pass it to
-     * getNearbyColourIndex if you need one that is.
+     * according to some simple algorithm. The returned colour is not
+     * necessarily in the database; pass it to getNearbyColourIndex if
+     * you need one that is.
      */
     QColor getContrastingColour(int c) const;