-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: ddc3a6c736c902f90432398de8bba9d6655e5306:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit ddc3a6c736c902f90432398de8bba9d6655e5306
Author: Marc Lehmann <schmorp@schmorp.de>
Date:   Sun Dec 14 04:52:10 2014 +0000

    ugh

diff --git a/Changes b/Changes

index 4a7a44d76f869d032b9a2c9ffaa2f23f637d17cf..

index ..a567fc86d51c1905570f3ad2b912b1ab51d53b9b 100644

--- a/Changes
+++ b/Changes
@@ -89,6 +89,9 @@ TODO: open question, what does the nested set_color calls in get_coplours actual
           simpler and actually more correct code.
         - hopefully no longer leak colours on !truecolor visuals.
         - use consistent method names (scr_recolour => scr_recolor).
+        - use simpler (but slightly less bogus) formula for nearest
+          colour choice (this is likely only relevant for antique 8bpp
+          frame buffers).

 9.20 Sat Apr 26 16:22:27 CEST 2014
         - (libptytty) fix bug that prevented urxvtd from writing utmp
diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C

index 5411118aaae731c875b98cd664748b3cac43b91f..

index ..3f275fa57d73a7fc44e54f7d2c8c004e0d95334c 100644

--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -25,6 +25,8 @@
 #include <rxvt.h>
 #include <rxvttoolkit.h>

+#include <stdlib.h>
+
 #include <unistd.h>
 #include <fcntl.h>

@@ -809,7 +811,8 @@ rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
     return true;
 #endif

-  c.pixel = (color.r + color.g + color.b) > 128*3
+  //TODO: set c.color* or c.*
+  c.pixel = (color.r * 2 + color.g * 3 + color.b) >= 0x8000 * 6
           ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy))
           : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy));

@@ -879,14 +882,15 @@ rxvt_color::set (rxvt_screen *screen, const rgba &color)

       while (cmap_size)
         {
-          int diff = 0x7fffffffUL;
+          int diff = 0x7fffffffL;
           XColor *best = colors;

           for (int i = 0; i < cmap_size; i++)
             {
-              int d = (squared_diff<int> (color.r >> 2, colors [i].red   >> 2))
-                    + (squared_diff<int> (color.g >> 2, colors [i].green >> 2))
-                    + (squared_diff<int> (color.b >> 2, colors [i].blue  >> 2));
+              // simple weighted rgb distance sucks, but keeps it simple
+              int d = abs (color.r - colors [i].red  ) * 2
+                    + abs (color.g - colors [i].green) * 3
+                    + abs (color.b - colors [i].blue );

               if (d < diff)
                 {
@@ -917,6 +921,7 @@ void
 rxvt_color::get (rgba &color) const
 {
 #if XFT
+  //TODO premultiplied alpha??
   color.r = c.color.red;
   color.g = c.color.green;
   color.b = c.color.blue;
diff --git a/src/rxvtutil.h b/src/rxvtutil.h

index f08c70900d9d496867196ac89bb36d7186e5f3fb..

index ..9d252d9880df5c77bc5698e229ae58341ddfbdd9 100644

--- a/src/rxvtutil.h
+++ b/src/rxvtutil.h
@@ -24,8 +24,6 @@ template<typename T, typename U> static inline void max_it (T &a, U b) { a = a >
 template<typename T, typename U, typename V> static inline T    clamp    (T  v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; }
 template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) {    v = v < (T)a ? a : v >(T)b ? b : v; }

-template<typename T> static inline T squared_diff (T a, T b) { return (a - b) * (a - b); }
-
 // linear interpolation
 template<typename T, typename U, typename P>
 static inline T

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 12:22:02 2024