|
3 | 3 | * MathJax/extensions/TeX/color.js
|
4 | 4 | *
|
5 | 5 | * Implements LaTeX-compatible \color macro rather than MathJax's
|
6 |
| - * original (non-standard) version. It includes the rgb, gray, and |
7 |
| - * named color models, and the \definecolor macro. |
| 6 | + * original (non-standard) version. It includes the rgb, RGB, gray, |
| 7 | + * and named color models, and the \definecolor macro. |
8 | 8 | *
|
9 | 9 | * ---------------------------------------------------------------------
|
10 | 10 | *
|
|
27 | 27 | // The configuration defaults, augmented by the user settings
|
28 | 28 | //
|
29 | 29 | MathJax.Extension["TeX/color"] = {
|
30 |
| - version: "2.0.1", |
| 30 | + version: "2.0.2", |
31 | 31 |
|
32 | 32 | config: MathJax.Hub.CombineConfig("TeX.color",{
|
33 | 33 | padding: "5px",
|
@@ -116,21 +116,37 @@ MathJax.Extension["TeX/color"] = {
|
116 | 116 | },
|
117 | 117 |
|
118 | 118 | /*
|
119 |
| - * Get an RGB color |
| 119 | + * Get an rgb color |
120 | 120 | */
|
121 | 121 | get_rgb: function (rgb) {
|
122 | 122 | rgb = rgb.split(/,/); var RGB = "#";
|
123 |
| - if (rgb.length !== 3) {this.TEX.Error("RGB colors require 3 decimal numbers")} |
| 123 | + if (rgb.length !== 3) {this.TEX.Error("rgb colors require 3 decimal numbers")} |
124 | 124 | for (var i = 0; i < 3; i++) {
|
125 | 125 | if (!rgb[i].match(/^(\d+(\.\d*)?|\.\d+)$/)) {this.TEX.Error("Invalid decimal number")}
|
126 | 126 | var n = parseFloat(rgb[i]);
|
127 |
| - if (n < 0 || n > 1) {this.TEX.Error("RGB values must be between 0 and 1")} |
| 127 | + if (n < 0 || n > 1) {this.TEX.Error("rgb values must be between 0 and 1")} |
128 | 128 | n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n}
|
129 | 129 | RGB += n;
|
130 | 130 | }
|
131 | 131 | return RGB;
|
132 | 132 | },
|
133 | 133 |
|
| 134 | + /* |
| 135 | + * Get an RGB color |
| 136 | + */ |
| 137 | + get_RGB: function (rgb) { |
| 138 | + rgb = rgb.split(/,/); var RGB = "#"; |
| 139 | + if (rgb.length !== 3) {this.TEX.Error("RGB colors require 3 numbers")} |
| 140 | + for (var i = 0; i < 3; i++) { |
| 141 | + if (!rgb[i].match(/^\d+$/)) {this.TEX.Error("Invalid number")} |
| 142 | + var n = parseInt(rgb[i]); |
| 143 | + if (n > 255) {this.TEX.Error("RGB values must be between 0 and 255")} |
| 144 | + n = n.toString(16); if (n.length < 2) {n = "0"+n} |
| 145 | + RGB += n; |
| 146 | + } |
| 147 | + return RGB; |
| 148 | + }, |
| 149 | + |
134 | 150 | /*
|
135 | 151 | * Get a gray-scale value
|
136 | 152 | */
|
|
0 commit comments