freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master ad444be 2/2: [ftstring] Enable changing display


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master ad444be 2/2: [ftstring] Enable changing display color.
Date: Mon, 23 Nov 2015 04:18:20 +0000

branch: master
commit ad444be73698a1763327b0c3d0bbb17b6a4ad9d9
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [ftstring] Enable changing display color.
    
    * src/ftstring.c (event_color_change): New function.
    (Process_Event) [grKeySpace]: New event to change color.
    (event_help): Offer it.
    (main): Updated.
    * src/ftstring.1: Updated.
---
 ChangeLog      |   10 ++++++++++
 src/ftstring.1 |    4 ++--
 src/ftstring.c |   27 ++++++++++++++++++++++-----
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index efc6037..d08eac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2015-11-22  Alexei Podtelezhnikov  <address@hidden>
 
+       [ftstring] Enable changing display color.
+
+       * src/ftstring.c (event_color_change): New function.
+       (Process_Event) [grKeySpace]: New event to change color.
+       (event_help): Offer it.
+       (main): Updated.
+       * src/ftstring.1: Updated.
+
+2015-11-22  Alexei Podtelezhnikov  <address@hidden>
+
        [ftstring] Use shared `grSetGlyphGamma'.
 
        * src/ftcommon.h (FTDemo_String_Context): Remove `gamma_ramp'.
diff --git a/src/ftstring.1 b/src/ftstring.1
index b996e64..6724a92 100644
--- a/src/ftstring.1
+++ b/src/ftstring.1
@@ -16,8 +16,8 @@ ftstring \- string viewer
 .SH DESCRIPTION
 .
 .B ftstring
-displays a text string with the given font (white on black), allowing
-to change various rendering and display options interactively.
+displays a text string with the given font, allowing to change
+various rendering and display options interactively.
 .
 .TP
 .B pt
diff --git a/src/ftstring.c b/src/ftstring.c
index 05ec47d..fb06950 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -115,6 +115,7 @@
     grWriteln( "  k         : cycle through kerning modes" );
     grWriteln( "  t         : cycle through kerning degrees" );
     grWriteln( "  V         : toggle vertical rendering" );
+    grWriteln( "  space     : cycle through color" );
     grLn();
     grWriteln( "  g         : increase gamma by 0.1" );
     grWriteln( "  v         : decrease gamma by 0.1" );
@@ -190,6 +191,22 @@
 
 
   static void
+  event_color_change()
+  {
+    static int     i = 0;
+    unsigned char  r = i & 4 ? 0xff : 0;
+    unsigned char  g = i & 2 ? 0xff : 0;
+    unsigned char  b = i & 1 ? 0xff : 0;
+
+
+    display->back_color = grFindColor( display->bitmap,  r,  g,  b, 0xff );
+    display->fore_color = grFindColor( display->bitmap, ~r, ~g, ~b, 0xff );
+
+    i++;
+  }
+
+
+  static void
   event_gamma_change( double  delta )
   {
     int     i;
@@ -346,6 +363,10 @@
                       : (char *)"using horizontal layout";
       break;
 
+    case grKeySpace:
+      event_color_change();
+      break;
+
     case grKEY( 'g' ):
       event_gamma_change( 0.1 );
       break;
@@ -618,14 +639,10 @@
     if ( !display )
       PanicZ( "could not allocate display surface" );
 
-    display->back_color = grFindColor( display->bitmap,
-                                       0x00, 0x00, 0x00, 0xff );
-    display->fore_color = grFindColor( display->bitmap,
-                                       0xff, 0xff, 0xff, 0xff );
-
     grSetTitle( display->surface,
                 "FreeType String Viewer - press ? for help" );
 
+    event_color_change();
     event_gamma_change( 0 );
     event_font_change( 0 );
     status.header = 0;



reply via email to

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