summaryrefslogtreecommitdiff
path: root/scripts/generate-style-code.js
diff options
context:
space:
mode:
authorMolly Lloyd <molly@mapbox.com>2018-06-14 14:35:39 -0700
committerMolly Lloyd <mollymerp@users.noreply.github.com>2018-08-31 13:08:47 -0700
commit4a5dc37245d23805d13865f5ef9c5f26e539a9ca (patch)
treede77bfeff6f7afbe02210c9189bf72da59293083 /scripts/generate-style-code.js
parentec62e321531b1a836074056e86de8e20018280fb (diff)
downloadqtlocation-mapboxgl-4a5dc37245d23805d13865f5ef9c5f26e539a9ca.tar.gz
[core] Implement CrossFadedDataDrivenProperty to add support for feature expressions in `*-pattern` properties
Diffstat (limited to 'scripts/generate-style-code.js')
-rwxr-xr-xscripts/generate-style-code.js37
1 files changed, 22 insertions, 15 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js
index f85c6d8fd0..8b9b6ba5a2 100755
--- a/scripts/generate-style-code.js
+++ b/scripts/generate-style-code.js
@@ -56,21 +56,27 @@ global.evaluatedType = function (property) {
function attributeUniformType(property, type) {
const attributeNameExceptions = {
- 'text-opacity': 'opacity',
- 'icon-opacity': 'opacity',
- 'text-color': 'fill_color',
- 'icon-color': 'fill_color',
- 'text-halo-color': 'halo_color',
- 'icon-halo-color': 'halo_color',
- 'text-halo-blur': 'halo_blur',
- 'icon-halo-blur': 'halo_blur',
- 'text-halo-width': 'halo_width',
- 'icon-halo-width': 'halo_width',
- 'line-gap-width': 'gapwidth'
+ 'text-opacity': ['opacity'],
+ 'icon-opacity': ['opacity'],
+ 'text-color': ['fill_color'],
+ 'icon-color': ['fill_color'],
+ 'text-halo-color': ['halo_color'],
+ 'icon-halo-color': ['halo_color'],
+ 'text-halo-blur': ['halo_blur'],
+ 'icon-halo-blur': ['halo_blur'],
+ 'text-halo-width': ['halo_width'],
+ 'icon-halo-width': ['halo_width'],
+ 'line-gap-width': ['gapwidth'],
+ 'line-pattern': ['pattern_to', 'pattern_from'],
+ 'fill-pattern': ['pattern_to', 'pattern_from'],
+ 'fill-extrusion-pattern': ['pattern_to', 'pattern_from']
}
- const name = attributeNameExceptions[property.name] ||
- property.name.replace(type + '-', '').replace(/-/g, '_');
- return `attributes::a_${name}${name === 'offset' ? '<1>' : ''}, uniforms::u_${name}`;
+ const names = attributeNameExceptions[property.name] ||
+ [ property.name.replace(type + '-', '').replace(/-/g, '_') ];
+
+ return names.map(name => {
+ return `attributes::a_${name}${name === 'offset' ? '<1>' : ''}, uniforms::u_${name}`
+ }).join(', ');
}
global.layoutPropertyType = function (property) {
@@ -86,8 +92,9 @@ global.layoutPropertyType = function (property) {
global.paintPropertyType = function (property, type) {
switch (property['property-type']) {
case 'data-driven':
- case 'cross-faded-data-driven':
return `DataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}>`;
+ case 'cross-faded-data-driven':
+ return `CrossFadedDataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}>`;
case 'cross-faded':
return `CrossFadedPaintProperty<${evaluatedType(property)}>`;
default: