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 :: [(Double, Double)]
corners = (,) <$> [0, 1] <*> [0, 1] corners = (,) <$> [0, 1] <*> [0, 1]
shapeCircumference :: [Point V2 Double] -> Double
shapeCircumference = Data.List.sum . map D.norm . loopOffsets . fromVertices shapeCircumference = Data.List.sum . map D.norm . loopOffsets . fromVertices
genImage' :: Image VU G.RGB Double -> StdGen -> Int -> QDiagram SVG V2 Double Any genImage' :: Image VU G.RGB Double -> StdGen -> Int -> QDiagram SVG V2 Double Any

View file

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