octave-maintainers
[Top][All Lists]
Advanced

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

Text color property


From: David Bateman
Subject: Text color property
Date: Fri, 24 Aug 2007 14:35:07 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Here is a small patch that someone here requested that adds the text
color property.. This allows things like

plot(randn(1000,1))
text(400,3,"label","Color",[0,1,0])

to work correctly.

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

*** ./scripts/plot/__go_draw_axes__.m.orig9     2007-08-24 14:23:02.922989203 
+0200
--- ./scripts/plot/__go_draw_axes__.m   2007-08-24 14:28:33.845267665 +0200
***************
*** 599,620 ****
          halign = obj.horizontalalignment;
          angle = obj.rotation;
            units = obj.units;
            if (strcmpi (units, "normalized"))
              units = "graph";
            else
              units = "";
            endif
          
          if (nd == 3)
            fprintf (plot_stream,
!                    "set label \"%s\" at %s %g,%g,%g %s rotate by %f;\n",
                     undo_string_escapes (label), units,
!                    lpos(1), lpos(2), lpos(3), halign, angle);
          else
            fprintf (plot_stream,
!                    "set label \"%s\" at %s %g,%g %s rotate by %f;\n",
                     undo_string_escapes (label), units,
!                    lpos(1), lpos(2), halign, angle);
          endif
  
        otherwise
--- 599,649 ----
          halign = obj.horizontalalignment;
          angle = obj.rotation;
            units = obj.units;
+         color = obj.color;
            if (strcmpi (units, "normalized"))
              units = "graph";
            else
              units = "";
            endif
          
+         if (isnumeric (color))
+           if (have_newer_gnuplot)
+             colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"",
+                      round (255*color));
+           else
+             if (isequal (color, [0,0,0]))
+               typ = -1;
+             elseif (isequal (color, [1,0,0]))
+               typ = 1;
+             elseif (isequal (color, [0,1,0]))
+               typ = 2;
+             elseif (isequal (color, [0,0,1]))
+               typ = 3;
+             elseif (isequal (color, [1,0,1]))
+               typ = 4;
+             elseif (isequal (color, [0,1,1]))
+               typ = 5;
+             elseif (isequal (color, [1,1,1]))
+               typ = -1;
+             elseif (isequal (color, [1,1,0]))
+               typ = 7;
+             else
+               typ = -1;
+             endif
+             colorspec = sprintf ("textcolor lt %d", typ);
+           endif
+         endif
+ 
          if (nd == 3)
            fprintf (plot_stream,
!                    "set label \"%s\" at %s %g,%g,%g %s rotate by %f %s;\n",
                     undo_string_escapes (label), units,
!                    lpos(1), lpos(2), lpos(3), halign, angle, colorspec);
          else
            fprintf (plot_stream,
!                    "set label \"%s\" at %s %g,%g %s rotate by %f %s;\n",
                     undo_string_escapes (label), units,
!                    lpos(1), lpos(2), halign, angle, colorspec);
          endif
  
        otherwise
*** ./src/graphics.cc.orig9     2007-08-24 14:22:46.046842031 +0200
--- ./src/graphics.cc   2007-08-24 14:22:15.842368417 +0200
***************
*** 1800,1806 ****
      units ("data"),
      position (Matrix (1, 3, 0.0)),
      rotation (0),
!     horizontalalignment ("left")
  { }
  
  void
--- 1800,1807 ----
      units ("data"),
      position (Matrix (1, 3, 0.0)),
      rotation (0),
!     horizontalalignment ("left"),
!     color (Matrix (1, 3, 1.0))
  { }
  
  void
***************
*** 1827,1832 ****
--- 1828,1835 ----
      rotation = val;
    else if (name.compare ("horizontalalignment"))
      horizontalalignment = val;
+   else if (name.compare ("color"))
+     color = val;
    else
      {
        modified = false;
***************
*** 1851,1856 ****
--- 1854,1860 ----
    m.assign ("position", position);
    m.assign ("rotation", rotation);
    m.assign ("horizontalalignment", horizontalalignment);
+   m.assign ("color", color);
  
    return m;
  }
***************
*** 1878,1883 ****
--- 1882,1889 ----
      retval = rotation;
    else if (name.compare ("horizontalalignment"))
      retval = horizontalalignment;
+   else if (name.compare ("color"))
+     retval = color;
    else
      warning ("get: invalid property `%s'", name.c_str ());
  
***************
*** 1894,1899 ****
--- 1900,1906 ----
    m["position"] = Matrix (1, 3, 0.0);
    m["rotation"] = 0;
    m["horizontalalignment"] = "left";
+   m["color"] = Matrix (1, 3, 1.0);
  
    return m;
  }
*** ./src/graphics.h.orig9      2007-08-24 14:22:38.480224408 +0200
--- ./src/graphics.h    2007-08-24 14:10:26.708209355 +0200
***************
*** 1446,1451 ****
--- 1446,1452 ----
      octave_value position;
      octave_value rotation;
      octave_value horizontalalignment;
+     octave_value color;
  
      static std::string go_name;
    };
2007-08-24  David Bateman  <address@hidden>

        * graphics.h (class text): Add property color.
        * graphics.cc (text::text_properties::text_properties) ditto.
        (text::text_properties::set): ditto.
        (text::text_properties::get): ditto.
        (text::text_properties::factory_defaults): ditto.

2007-08-24  David Bateman  <address@hidden>

        * plot/__go_draw_axes__.m: Treat text color property.

reply via email to

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