Skip to content

Commit 78cf0fe

Browse files
committed
Set the nerve cuff line-width to be fixed and reduce its opacity when dimmed (#68).
1 parent abb0577 commit 78cf0fe

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

src/layers/styling.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -992,42 +992,42 @@ export class FeatureNerveLayer extends VectorStyleLayer
992992
]
993993
}
994994

995+
paintStyle(options: StylingOptions, changes=false) {
996+
const dimmed = options.dimmed || false
997+
const paintStyle: PaintSpecification = {
998+
'line-color': [
999+
'case',
1000+
['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
1001+
['boolean', ['feature-state', 'active'], false], NERVE_ACTIVE,
1002+
['boolean', ['feature-state', 'selected'], false], NERVE_SELECTED,
1003+
'#888'
1004+
],
1005+
'line-opacity': [
1006+
'case',
1007+
['boolean', ['feature-state', 'hidden'], false], 0.3,
1008+
['boolean', ['get', 'invisible'], false], 0.001,
1009+
['boolean', ['feature-state', 'active'], false], 0.9,
1010+
['boolean', ['feature-state', 'selected'], false], 0.9,
1011+
dimmed ? 0.05 : 0.9
1012+
],
1013+
'line-dasharray': [2, 2],
1014+
'line-width': [
1015+
'case',
1016+
['boolean', ['feature-state', 'selected'], false], 1.5,
1017+
['boolean', ['feature-state', 'active'], false], 1.5,
1018+
dimmed ? 0.2 : 1.5
1019+
]
1020+
}
1021+
return super.changedPaintStyle(paintStyle, changes)
1022+
}
1023+
9951024
style(layer: FlatMapLayer, options: StylingOptions): LineLayerSpecification
9961025
{
9971026
return {
9981027
...super.style(layer, options),
9991028
'type': 'line',
10001029
'filter': this.defaultFilter(),
1001-
'paint': {
1002-
'line-color': [
1003-
'case',
1004-
['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
1005-
['boolean', ['feature-state', 'selected'], false], NERVE_SELECTED,
1006-
['boolean', ['feature-state', 'active'], false], NERVE_ACTIVE,
1007-
'#888'
1008-
],
1009-
'line-opacity': [
1010-
'case',
1011-
['boolean', ['feature-state', 'hidden'], false], 0.3,
1012-
['boolean', ['get', 'invisible'], false], 0.001,
1013-
['boolean', ['feature-state', 'active'], false], 0.9,
1014-
['boolean', ['feature-state', 'selected'], false], 0.9,
1015-
0.9
1016-
],
1017-
'line-dasharray': [2, 1],
1018-
'line-width': [
1019-
'let', 'width', ['case',
1020-
['boolean', ['feature-state', 'active'], false], 0.8,
1021-
['boolean', ['feature-state', 'selected'], false], 1.2,
1022-
0.6],
1023-
[ 'interpolate',
1024-
['exponential', 2],
1025-
['zoom'],
1026-
2, ["*", ['var', 'width'], ["^", 2, -1]],
1027-
10, ["*", ['var', 'width'], ["^", 2, 6]]
1028-
]
1029-
]
1030-
}
1030+
'paint': this.paintStyle(options) as LinePaintSpecification
10311031
}
10321032
}
10331033
}
@@ -1137,7 +1137,7 @@ export class NervePolygonFill extends VectorStyleLayer
11371137
['==', ['get', 'type'], 'arrow'],
11381138
['==', ['get', 'type'], 'junction']
11391139
], dimmed ? 0.1 : 0.5,
1140-
0.5
1140+
dimmed ? 0.2 : 0.5
11411141
]
11421142
}
11431143
return super.changedPaintStyle(paintStyle, changes)

0 commit comments

Comments
 (0)