Skip to content

Commit

Permalink
Fade things outside the edited neighbourhood. #27
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Apr 19, 2024
1 parent cf62b9a commit ffa961d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
35 changes: 34 additions & 1 deletion web/src/RenderNeighbourhood.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { RenderNeighbourhoodOutput } from "./wasm";
import OneWayLayer from "./OneWayLayer.svelte";
import type { Feature } from "geojson";
import type { Feature, Polygon } from "geojson";
import {
hoverStateFilter,
FillLayer,
Expand Down Expand Up @@ -39,9 +39,42 @@
],
"blue",
);
function invertBoundary(gj: RenderNeighbourhoodOutput): Feature<Polygon> {
// @ts-expect-error TS can't figure out that we're narrowing the case here
let boundary: Feature<Polygon> = gj.features.find(
(f) => f.properties.kind == "boundary",
)!;
return {
type: "Feature",
properties: {},
geometry: {
type: "Polygon",
coordinates: [
[
[180.0, 90.0],
[-180.0, 90.0],
[-180.0, -90.0],
[180.0, -90.0],
[180.0, 90.0],
],
// One hole
boundary.geometry.coordinates[0],
],
},
};
}
</script>

<GeoJSON data={gj} generateId>
<GeoJSON data={invertBoundary(gj)}>
<FillLayer
{...layerId("neighbourhood-boundary")}
paint={{ "fill-color": "black", "fill-opacity": 0.3 }}
/>
</GeoJSON>

<FillLayer
{...layerId("cells")}
filter={["==", ["get", "kind"], "cell"]}
Expand Down
1 change: 1 addition & 0 deletions web/src/common/zorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const layerZorder = [
"modal-filters",

"boundary",
"neighbourhood-boundary",

"freehand-line",

Expand Down

0 comments on commit ffa961d

Please sign in to comment.