keid-geometry 0.1.1.2 → 0.1.1.3
raw patch · 3 files changed
+36/−3 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Geometry.Tile.Neighbors: fromPoints :: Vec2 -> Vec2 -> Neighbors Vec2
Files
- ChangeLog.md +4/−0
- keid-geometry.cabal +3/−3
- src/Geometry/Tile/Neighbors.hs +29/−0
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for keid-geometry +## 0.1.1.3++- Added `Neighbors.fromPoints` to generate the whole block from corners.+ ## 0.1.1.2 - Added `Geometry.Tile.Neighbors` collection and bitset-based adjacency tests.
keid-geometry.cabal view
@@ -1,16 +1,16 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.35.1. -- -- see: https://github.com/sol/hpack name: keid-geometry-version: 0.1.1.2+version: 0.1.1.3 synopsis: Geometry primitives for Keid engine. category: Game Engine author: IC Rainbow maintainer: keid@aenor.ru-copyright: 2021 IC Rainbow+copyright: 2023 IC Rainbow license: BSD3 license-file: LICENSE build-type: Simple
src/Geometry/Tile/Neighbors.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE NoStrictData #-}+ module Geometry.Tile.Neighbors ( Neighbors(..) , nobody@@ -11,11 +13,14 @@ , directionsWith , isCorner , names++ , fromPoints ) where import RIO import Data.Bits+import Geomancy.Vec2 (Vec2, withVec2, vec2) import Resource.Collection (Generic1, Generically1(..), enumerate) nobody :: Neighbors Bool@@ -97,3 +102,27 @@ , southWest = "sw" , west = "w" }++fromPoints :: Vec2 -> Vec2 -> Neighbors Vec2+fromPoints a b =+ withVec2 a \ax ay ->+ withVec2 b \bx by ->+ let+ top = min ay by+ right = max ax bx+ bottom = max ay by+ left = min ax bx++ midX = ax * 0.5 + bx * 0.5+ midY = ay * 0.5 + by * 0.5+ in+ Neighbors+ { northWest = vec2 left top+ , north = vec2 midX top+ , northEast = vec2 right top+ , east = vec2 right midY+ , southEast = vec2 right bottom+ , south = vec2 midX bottom+ , southWest = vec2 left bottom+ , west = vec2 left midY+ }