Skip to content

Commit 5cd8dfe

Browse files
#655 Configurable Tile Layer Brightness, Contrast and Saturation (#659)
1 parent 2803eb8 commit 5cd8dfe

File tree

3 files changed

+212
-59
lines changed

3 files changed

+212
-59
lines changed

configure/src/metaconfigs/layer-tile-config.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,57 @@
261261
}
262262
]
263263
},
264+
{
265+
"name": "Style",
266+
"rows": [
267+
{
268+
"name": "Filters",
269+
"components": [
270+
{
271+
"field": "style.brightness",
272+
"name": "Brightness",
273+
"description": "The brightness filter applies a linear multiplier over the tile layer, making it appear brighter or darker. A value of 0 renders a completely black image. A value of 1 leaves the image unchanged. A value greater than 1 brightens. Default 1.",
274+
"type": "slider",
275+
"default": 1,
276+
"min": 0,
277+
"max": 3,
278+
"step": 0.05,
279+
"width": 3
280+
},
281+
{
282+
"field": "style.contrast",
283+
"name": "Contrast",
284+
"description": "The contrast filter adjusts the contrast of the tile layer. A value of 0 renders a completely gray image. A value of 1 leaves the image unchanged. A value greater than 1 exaggerates the contrast. Default 1.",
285+
"type": "slider",
286+
"default": 1,
287+
"min": 0,
288+
"max": 4,
289+
"step": 0.05,
290+
"width": 3
291+
},
292+
{
293+
"field": "style.saturation",
294+
"name": "Saturation",
295+
"description": "The saturation filter super-saturates or desaturates the colors of the tile layer. A value of 0 renders a greyscale image. A value of 1 leaves the image unchanged. A value greater than 1 super-saturates. Default 1.",
296+
"type": "slider",
297+
"default": 1,
298+
"min": 0,
299+
"max": 4,
300+
"step": 0.05,
301+
"width": 3
302+
},
303+
{
304+
"field": "style.blend",
305+
"name": "Blend",
306+
"description": "Specifies how this tile layer should blend with the tile layers beneath it. Default 'none'.",
307+
"type": "dropdown",
308+
"width": 3,
309+
"options": ["none", "color", "overlay"]
310+
}
311+
]
312+
}
313+
]
314+
},
264315
{
265316
"name": "Time",
266317
"rows": [

src/essence/Basics/Map_/Map_.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,44 @@ async function makeTileLayer(layerObj) {
11791179
})
11801180
L_.layers.layer[layerObj.name].off('load')
11811181
L_.layers.layer[layerObj.name].on('load', () => {
1182+
// Set default css filters for tile layer
1183+
if (
1184+
layerObj.style?.brightness != null &&
1185+
L_.layers.filters[layerObj.name]?.brightness == null
1186+
)
1187+
L_.setLayerFilter(
1188+
layerObj.name,
1189+
'brightness',
1190+
layerObj.style.brightness
1191+
)
1192+
if (
1193+
layerObj.style?.contrast != null &&
1194+
L_.layers.filters[layerObj.name]?.contrast == null
1195+
)
1196+
L_.setLayerFilter(
1197+
layerObj.name,
1198+
'contrast',
1199+
layerObj.style.contrast
1200+
)
1201+
if (
1202+
layerObj.style?.saturation != null &&
1203+
L_.layers.filters[layerObj.name]?.saturation == null
1204+
)
1205+
L_.setLayerFilter(
1206+
layerObj.name,
1207+
'saturation',
1208+
layerObj.style.saturation
1209+
)
1210+
if (
1211+
layerObj.style?.blend != null &&
1212+
L_.layers.filters[layerObj.name]?.blend == null
1213+
)
1214+
L_.setLayerFilter(
1215+
layerObj.name,
1216+
'mix-blend-mode',
1217+
layerObj.style.blend
1218+
)
1219+
11821220
L_.setGlobalLoaded(layerObj.name)
11831221
})
11841222
allLayersLoaded()

0 commit comments

Comments
 (0)