Mercurial > hg > octave-nkf
comparison src/graphics.cc @ 6925:1401a79af68c
[project @ 2007-09-26 18:58:52 by dbateman]
author | dbateman |
---|---|
date | Wed, 26 Sep 2007 18:58:53 +0000 |
parents | f4e1bdb66535 |
children | 688ef9440022 |
comparison
equal
deleted
inserted
replaced
6924:be176b7e110a | 6925:1401a79af68c |
---|---|
88 { | 88 { |
89 double tmp_rgb[3] = {0, 0, 0}; | 89 double tmp_rgb[3] = {0, 0, 0}; |
90 bool retval = true; | 90 bool retval = true; |
91 unsigned int len = str.length(); | 91 unsigned int len = str.length(); |
92 | 92 |
93 std::transform (str.begin (), str.end (), str.begin (), tolower); | |
94 | |
93 if (str.compare(0, len, "blue", 0, len) == 0) | 95 if (str.compare(0, len, "blue", 0, len) == 0) |
94 tmp_rgb[2] = 1; | 96 tmp_rgb[2] = 1; |
95 else if (str.compare(0, len, "black", 0, len) == 0 || str.compare(0, len, "w", 0, len) == 0) | 97 else if (str.compare(0, len, "black", 0, len) == 0 || |
98 str.compare(0, len, "k", 0, len) == 0) | |
96 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; | 99 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; |
97 else if (str.compare(0, len, "red", 0, len) == 0) | 100 else if (str.compare(0, len, "red", 0, len) == 0) |
98 tmp_rgb[0] = 1; | 101 tmp_rgb[0] = 1; |
99 else if (str.compare(0, len, "green", 0, len) == 0) | 102 else if (str.compare(0, len, "green", 0, len) == 0) |
100 tmp_rgb[1] = 1; | 103 tmp_rgb[1] = 1; |
102 tmp_rgb[0] = tmp_rgb[1] = 1; | 105 tmp_rgb[0] = tmp_rgb[1] = 1; |
103 else if (str.compare(0, len, "magenta", 0, len) == 0) | 106 else if (str.compare(0, len, "magenta", 0, len) == 0) |
104 tmp_rgb[0] = tmp_rgb[2] = 1; | 107 tmp_rgb[0] = tmp_rgb[2] = 1; |
105 else if (str.compare(0, len, "cyan", 0, len) == 0) | 108 else if (str.compare(0, len, "cyan", 0, len) == 0) |
106 tmp_rgb[1] = tmp_rgb[2] = 1; | 109 tmp_rgb[1] = tmp_rgb[2] = 1; |
107 else if (str.compare(0, len, "white", 0, len) == 0) | 110 else if (str.compare(0, len, "white", 0, len) == 0 || |
111 str.compare(0, len, "w", 0, len) == 0) | |
108 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; | 112 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; |
109 else | 113 else |
110 retval = false; | 114 retval = false; |
111 | 115 |
112 if (retval) | 116 if (retval) |
116 } | 120 } |
117 | 121 |
118 return retval; | 122 return retval; |
119 } | 123 } |
120 | 124 |
121 color_property::color_property (const octave_value& val) | 125 color_property::color_property (const octave_value& val, const radio_values &v) |
122 : radio_val (), current_val () | 126 : radio_val (v), current_val () |
123 { | 127 { |
124 // FIXME -- need some error checking here. | 128 // FIXME -- need some error checking here. |
125 | 129 |
126 if (val.is_string ()) | 130 if (val.is_string ()) |
127 { | 131 { |
128 std::string s = val.string_value (); | 132 std::string s = val.string_value (); |
129 | 133 |
130 if (! s.empty ()) | 134 if (! s.empty ()) |
131 { | 135 { |
132 color_values col (s); | 136 if (radio_val.contains (s)) |
133 if (! error_state) | |
134 { | 137 { |
135 color_val = col; | 138 current_val = s; |
136 current_type = color_t; | 139 current_type = radio_t; |
140 } | |
141 else | |
142 { | |
143 color_values col (s); | |
144 if (! error_state) | |
145 { | |
146 color_val = col; | |
147 current_type = color_t; | |
148 } | |
137 } | 149 } |
138 } | 150 } |
139 else | 151 else |
140 error ("invalid color specification"); | 152 error ("invalid color specification"); |
141 } | 153 } |
2117 else if (name.compare ("ydata")) | 2129 else if (name.compare ("ydata")) |
2118 set_ydata (val); | 2130 set_ydata (val); |
2119 else if (name.compare ("zdata")) | 2131 else if (name.compare ("zdata")) |
2120 set_zdata (val); | 2132 set_zdata (val); |
2121 else if (name.compare ("facecolor")) | 2133 else if (name.compare ("facecolor")) |
2122 set_facecolor (val); | 2134 set_facecolor (color_property (val, radio_values ("flat|none|interp"))); |
2123 else if (name.compare ("facealpha")) | 2135 else if (name.compare ("facealpha")) |
2124 set_facealpha (val); | 2136 set_facealpha (val); |
2125 else if (name.compare ("edgecolor")) | 2137 else if (name.compare ("edgecolor")) |
2126 set_edgecolor (val); | 2138 set_edgecolor (val); |
2127 else if (name.compare ("linestyle")) | 2139 else if (name.compare ("linestyle")) |