freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 36a2ec0: [ftgrid] Key `C' now changes to a diff


From: Werner LEMBERG
Subject: [freetype2-demos] master 36a2ec0: [ftgrid] Key `C' now changes to a different color palette.
Date: Sun, 10 Sep 2017 04:31:06 -0400 (EDT)

branch: master
commit 36a2ec082040b72c859aca98cd083fc07da6773b
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [ftgrid] Key `C' now changes to a different color palette.
    
    This gives better support for color-blind people.
    
    * src/ftgrid.c (GridStatus): New member `do_alt_colors'.
    (grid_status_init, event_help): Updated.
    (grid_status_display): Move color code to...
    (grid_status_colors): ... this new function.
    (grof_status_alt_colors): New function.
    (Process_Event): Handle key `C'.
    (main): Updated.
---
 ChangeLog    | 14 ++++++++++++++
 src/ftgrid.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 03a1078..a472d8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2017-09-10  Werner Lemberg  <address@hidden>
+
+       [ftgrid] Key `C' now changes to a different color palette.
+
+       This gives better support for color-blind people.
+
+       * src/ftgrid.c (GridStatus): New member `do_alt_colors'.
+       (grid_status_init, event_help): Updated.
+       (grid_status_display): Move color code to...
+       (grid_status_colors): ... this new function.
+       (grof_status_alt_colors): New function.
+       (Process_Event): Handle key `C'.
+       (main): Updated.
+
 2017-09-09  Werner Lemberg  <address@hidden>
 
        Fix clang compiler warnings.
diff --git a/src/ftgrid.c b/src/ftgrid.c
index 8a57129..f05fabc 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -132,6 +132,7 @@
     int          do_blue_hints;
     int          do_segment;
     int          do_grid;
+    int          do_alt_colors;
 
     FT_LcdFilter lcd_filter;
     const char*  header;
@@ -174,6 +175,7 @@
     st->do_blue_hints = 1;
     st->do_segment    = 0;
     st->do_grid       = 1;
+    st->do_alt_colors = 0;
 
     st->Num           = 0;
     st->lcd_filter    = FT_LCD_FILTER_DEFAULT;
@@ -191,7 +193,13 @@
     st->disp_width    = display->bitmap->width;
     st->disp_height   = display->bitmap->rows;
     st->disp_bitmap   = display->bitmap;
+  }
+
 
+  static void
+  grid_status_colors( GridStatus       st,
+                      FTDemo_Display*  display )
+  {
     st->axis_color    = grFindColor( display->bitmap,   0,   0,   0, 255 ); /* 
black       */
     st->grid_color    = grFindColor( display->bitmap, 192, 192, 192, 255 ); /* 
gray        */
     st->outline_color = grFindColor( display->bitmap, 255,   0,   0, 255 ); /* 
red         */
@@ -203,6 +211,22 @@
 
 
   static void
+  grid_status_alt_colors( GridStatus       st,
+                          FTDemo_Display*  display )
+  {
+    /* colours are adjusted for color-blind people, */
+    /* cf. http://jfly.iam.u-tokyo.ac.jp/color      */
+    st->axis_color    = grFindColor( display->bitmap,   0,   0,   0, 255 ); /* 
black          */
+    st->grid_color    = grFindColor( display->bitmap, 192, 192, 192, 255 ); /* 
gray           */
+    st->outline_color = grFindColor( display->bitmap, 230, 159,   0, 255 ); /* 
orange         */
+    st->on_color      = grFindColor( display->bitmap, 230, 159,   0, 255 ); /* 
orange         */
+    st->off_color     = grFindColor( display->bitmap,  86, 180, 233, 255 ); /* 
sky blue       */
+    st->segment_color = grFindColor( display->bitmap, 204, 121, 167,  64 ); /* 
reddish purple */
+    st->blue_color    = grFindColor( display->bitmap,   0, 114, 178,  64 ); /* 
blue           */
+  }
+
+
+  static void
   grid_status_rescale_initial( GridStatus      st,
                                FTDemo_Handle*  handle )
   {
@@ -999,13 +1023,13 @@
     grWriteln( "f           toggle forced auto-         d           toggle dot 
display      " );
     grWriteln( "             hinting (if hinting)       o           toggle 
outline display  " );
     grWriteln( "G           toggle grid display         D           toggle 
dotnumber display" );
-    grWriteln( "                                                               
             " );
-    grWriteln( "F5, F6      cycle through               if Multiple Master or 
GX font:      " );
-    grWriteln( "             anti-aliasing modes          F2        cycle 
through axes      " );
-    grWriteln( "L           cycle through LCD             F3, F4    adjust 
current axis by  " );
-    grWriteln( "             filters                                 1/50th of 
its range    " );
-    grWriteln( "g, v        adjust gamma value                                 
             " );
-    grWriteln( "                                        q, ESC      quit 
ftgrid             " );
+    grWriteln( "C           change color palette                               
             " );
+    grWriteln( "                                        if Multiple Master or 
GX font:      " );
+    grWriteln( "F5, F6      cycle through                 F2        cycle 
through axes      " );
+    grWriteln( "             anti-aliasing modes          F3, F4    adjust 
current axis by  " );
+    grWriteln( "L           cycle through LCD                        1/50th of 
its range    " );
+    grWriteln( "             filters                                           
             " );
+    grWriteln( "g, v        adjust gamma value          q, ESC      quit 
ftgrid             " );
     /*          |----------------------------------|    
|----------------------------------| */
     grLn();
     grLn();
@@ -1546,6 +1570,20 @@
       break;
 #endif /* FT_DEBUG_AUTOFIT */
 
+    case grKEY( 'C' ):
+      status.do_alt_colors = !status.do_alt_colors;
+      if ( status.do_alt_colors )
+      {
+        status.header = "use alternative colors";
+        grid_status_alt_colors( &status, display );
+      }
+      else
+      {
+        status.header = "use default colors";
+        grid_status_colors( &status, display );
+      }
+      break;
+
     case grKEY( 'L' ):
       event_lcd_filter_change();
       break;
@@ -1952,6 +1990,7 @@
       Fatal( "could not allocate display surface" );
 
     grid_status_display( &status, display );
+    grid_status_colors(  &status, display );
 
     grSetTitle( display->surface,
                 "FreeType Glyph Grid Viewer - press ? for help" );



reply via email to

[Prev in Thread] Current Thread [Next in Thread]