voronoi spelling fix

This commit is contained in:
Jack Wines 2024-06-26 12:21:28 -04:00
parent 3b9d72b5e5
commit f7fca3fce3
No known key found for this signature in database
GPG key ID: 25B20640600571E6
2 changed files with 12 additions and 12 deletions

View file

@ -54,8 +54,8 @@ genImage image dimensionsVec minDistance gen =
. reflectY
. rectEnvelope (mkP2 0 0) (1 ^& 1)
. mconcat
. map ((\x -> drawVoroniRegion x <> overlayEdges x) . uncurry Tri.voroniDiagramCorners)
$ voroni
. map ((\x -> drawVoronoiRegion x <> overlayEdges x) . uncurry Tri.voronoiDiagramCorners)
$ voronoi
where
overlayEdges =
lw (local 0.001)
@ -63,9 +63,9 @@ genImage image dimensionsVec minDistance gen =
. strokeLocLoop
. fromVertices
drawVoroniRegion shape =
drawVoronoiRegion shape =
lw 0
. fillColor (Tri.voroniRegionAverageColor image dimensions shape)
. fillColor (Tri.voronoiRegionAverageColor image dimensions shape)
. strokeLocLoop
. fromVertices
$ shape
@ -76,9 +76,9 @@ genImage image dimensionsVec minDistance gen =
dimensions :: (Int, Int)
dimensions = (ceiling $ dimensionsVec ^. _x, ceiling $ dimensionsVec ^. _y)
singleVoroni = last voroni
singleVoronoi = last voronoi
voroni = map (\x -> (x, Tri.nClosestPoints 20 x corners')) corners'
voronoi = map (\x -> (x, Tri.nClosestPoints 20 x corners')) corners'
averageSideSize = (fromIntegral (uncurry (+) dimensions)) / 2

View file

@ -87,8 +87,8 @@ withinShape pointInShape verticies candidate = all ((< quarterTurn) . fmap abs .
sortOnAngle center = sortOn (normalizeAngle . signedAngleBetweenDirs xDir . dirBetween center)
voroniDiagramCorners :: (RealFloat n) => Point V2 n -> [Point V2 n] -> [Point V2 n]
voroniDiagramCorners center midpoints =
voronoiDiagramCorners :: (RealFloat n) => Point V2 n -> [Point V2 n] -> [Point V2 n]
voronoiDiagramCorners center midpoints =
sortOnAngle center
. filter isValidMidpoint
. concat
@ -155,8 +155,8 @@ nClosestPoints n p =
. takeSortOn n (abs . distanceA p)
. filter (/= p)
findVoroniDiagram :: (RealFloat n) => [(Point V2 n, Point V2 n)] -> [(Point V2 n, [Point V2 n])]
findVoroniDiagram =
findVoronoiDiagram :: (RealFloat n) => [(Point V2 n, Point V2 n)] -> [(Point V2 n, [Point V2 n])]
findVoronoiDiagram =
M.toList
. M.mapWithKey
( \key ->
@ -204,8 +204,8 @@ blendEqually colors = C.affineCombo (map (fraction,) colors) C.white
where
fraction = 1.0 / (fromIntegral . length $ colors)
voroniRegionAverageColor :: (Integral a, Integral b) => Ma.Image Ma.S (Co.SRGB 'Co.Linear) Double -> (a, b) -> [P2 Double] -> Colour Double
voroniRegionAverageColor image (x', y') =
voronoiRegionAverageColor :: (Integral a, Integral b) => Ma.Image Ma.S (Co.SRGB 'Co.Linear) Double -> (a, b) -> [P2 Double] -> Colour Double
voronoiRegionAverageColor image (x', y') =
blendEqually
. concatMap (getColorsInTriangle image (x', y'))
. filter ((== 3) . S.size)