[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.
This commit is contained in:
Konstantin Käfer
2016-07-07 11:31:45 +02:00
parent 32dcb34fc1
commit c88b05e110

View File

@@ -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) {