diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-07-07 11:31:45 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-07-07 11:33:42 +0200 |
commit | c88b05e1106e535edd99d16f3c19d9428b9605d2 (patch) | |
tree | 91f138d84e2cf485445740b044916b13fc0d5f53 /scripts/generate-style-code.js | |
parent | 32dcb34fc1dc733419c0f60918e74a734c7ee0bd (diff) | |
download | qtlocation-mapboxgl-c88b05e1106e535edd99d16f3c19d9428b9605d2.tar.gz |
[core] make code generator produce GL-compatible colors
this makes sure colors are premultiplied and the RGB values are in the 0..1 range rather than in the 0..255 range.
Diffstat (limited to 'scripts/generate-style-code.js')
-rw-r--r-- | scripts/generate-style-code.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 642da1174b..2a25f37112 100644 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -3,7 +3,14 @@ const fs = require('fs'); const ejs = require('ejs'); const spec = require('mapbox-gl-style-spec').latest; -var parseCSSColor = require('csscolorparser').parseCSSColor; +var colorParser = require('csscolorparser'); + +function parseCSSColor(str) { + var color = colorParser.parseCSSColor(str); + return [ + color[0] / 255 * color[3], color[1] / 255 * color[3], color[2] / 255 * color[3], color[3] + ]; +} global.camelize = function (str) { return str.replace(/(?:^|-)(.)/g, function (_, x) { |