This commit is contained in:
Jack Wines 2024-02-09 02:11:08 -08:00
parent a1337127e0
commit 8d9a69c24b
No known key found for this signature in database
GPG key ID: 25B20640600571E6
2 changed files with 8 additions and 4 deletions

View file

@ -55,6 +55,7 @@ convImage = Vec.map tosRGB' . Int.toVector
corners :: [(Double, Double)]
corners = (,) <$> [0, 1] <*> [0, 1]
shapeCircumference :: [Point V2 Double] -> Double
shapeCircumference = Data.List.sum . map D.norm . loopOffsets . fromVertices
genImage' :: Image VU G.RGB Double -> StdGen -> Int -> QDiagram SVG V2 Double Any

View file

@ -46,9 +46,11 @@ derivingUnbox
[|toSRGBTuple|]
[|fromSRGBTuple|]
borderSize = 0.05
-- from -0.05 to 1.05 so there aren't missing/elongated triangles at the edges
borderSize = 0.05
randomPoints :: StdGen -> [(Double, Double)]
randomPoints = map (bimap toZeroToOneTuple toZeroToOneTuple) . randomRs ((0 :: Word, 0 :: Word), (maxBound, maxBound))
where
@ -64,11 +66,12 @@ combinations xs =
. concat
. withStrategy (parListChunk 50 rdeepseq)
. map (\(x : xs) -> take 15 . sortOn (abs . uncurry distanceA) . map (x,) $ xs)
. init
. init -- last output of tails is empty list
. tails
$ xs
where
edgeLengthThreshold = 10
xsLen = length xs
toPlanarGraph :: forall n. (NFData n, Floating n, Ord n) => [P2 n] -> [(Point V2 n, Point V2 n)]
toPlanarGraph points =
@ -122,7 +125,7 @@ voroniDiagramCorners center midpoints =
where
-- implicitly uses the unit vector * 8 as an infinitely long vector
tangentVec =
scale 8
scale 2
. fromDirection
. rotateBy (1 / 4)
$ dirBetween midpoint center