commit 795e63d7732460bdf3644e62f5227c3f81d3d148
parent fb61919c96658bc6ac3eaf94ccbfbfdf8b73e190
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 23 Nov 2024 12:03:29 +0000
push tile bounds calc down into tiles from caller
Diffstat:
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm
@@ -527,8 +527,6 @@ canvas centre zoom width height model =
offsetY = pixelCentreY - (height // 2) - topedge
pixWidth = (1 + maxtile.x - mintile.x) * 256
pixHeight = (1 + maxtile.y - mintile.y) * 256
- xs = List.range mintile.x maxtile.x
- ys = List.range mintile.y maxtile.y
epos e = Tuple.mapBoth floor floor e.pointer.clientPos
tv = ifTrack model (trackView leftedge topedge zoom)
in div [style "position" "absolute"
@@ -540,7 +538,7 @@ canvas centre zoom width height model =
,Pointer.onUp (\e -> DragFinish (epos e))
,Pointer.onMove (\e -> Drag (epos e))
,Pointer.onDown (\e -> DragStart Map (epos e)) ]
- (tv :: tiles xs ys zoom)
+ (tv :: tiles centre zoom width height)
portalWidth = 600
diff --git a/frontend/src/TileMap.elm b/frontend/src/TileMap.elm
@@ -98,7 +98,11 @@ tileImg zoom tilenumber = img [ width 256,
height 256,
src (tileUrl tilenumber zoom) ] []
-tiles xs ys zoom =
+tiles centre zoom width height =
+ let (mintile, maxtile) = boundingTiles centre zoom width height
+ xs = List.range mintile.x maxtile.x
+ ys = List.range mintile.y maxtile.y
+ in
List.map
(\ y -> div []
(List.map (\ x -> tileImg zoom (TileNumber x y)) xs))