Changeset 69683
- Timestamp:
- Oct 6, 2016, 4:45:34 PM (8 years ago)
- Location:
- grass/trunk/lib/gis
- Files:
-
- 2 edited
-
color_str.c (modified) (1 diff)
-
testsuite/gis_lib_str_color.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/lib/gis/color_str.c
r63640 r69683 132 132 } 133 133 134 int hex; 135 136 if (sscanf(buf, "#%x", &hex) == 1) { 137 *red = (hex >> 16) & 0xFF; 138 *grn = (hex >> 8) & 0xFF; 139 *blu = hex & 0xFF; 140 if (*red < 0 || *red > 255 || 141 *grn < 0 || *grn > 255 || *blu < 0 || *blu > 255) 142 return 0; 143 144 return 1; 145 } 146 134 147 /* Look for this color in the standard (preallocated) colors */ 135 148 for (i = 0; i < num_names; i++) { -
grass/trunk/lib/gis/testsuite/gis_lib_str_color.py
r69682 r69683 65 65 self.convert_color(" 50:150:250 ", 50, 150, 250) 66 66 67 def test_html_hash_hex(self): 68 """Test HTML format with hash and hexadecimal (6 letters, #RRGGBB)""" 69 self.convert_color("#3296FA", 50, 150, 250) 70 71 def test_html_hash_hex_more_colors(self): 72 """Test HTML format with more colors""" 73 self.convert_color("#A6CEE3", 166, 206, 227) 74 self.convert_color("#33A02C", 51, 160, 44) 75 self.convert_color("#FB9A99", 251, 154, 153) 76 self.convert_color("#FF7F00", 255, 127, 0) 77 78 def test_html_hash_hex_more_colors_lowercase(self): 79 """Test HTML format with lowercase letters""" 80 self.convert_color("#a6cee3", 166, 206, 227) 81 self.convert_color("#33a02c", 51, 160, 44) 82 self.convert_color("#fb9a99", 251, 154, 153) 83 self.convert_color("#ff7f00", 255, 127, 0) 84 85 def test_html_hash_hex_more_colors_mixedcase(self): 86 """Test HTML format with mixed case letters""" 87 self.convert_color("#a6CeE3", 166, 206, 227) 88 self.convert_color("#33a02C", 51, 160, 44) 89 self.convert_color("#fB9A99", 251, 154, 153) 90 self.convert_color("#Ff7f00", 255, 127, 0) 91 92 def test_html_hash_hex_black(self): 93 """Test HTML format black color""" 94 self.convert_color("#000000", 0, 0, 0) 95 96 def test_html_hash_hex_white(self): 97 """Test HTML format white color""" 98 self.convert_color("#FFFFFF", 255, 255, 255) 99 67 100 def test_grass_named_black(self): 68 101 """Test GRASS GIS color black color"""
Note:
See TracChangeset
for help on using the changeset viewer.
