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 . reflectY
. rectEnvelope (mkP2 0 0) (1 ^& 1) . rectEnvelope (mkP2 0 0) (1 ^& 1)
. mconcat . mconcat
. map ((\x -> drawVoroniRegion x <> overlayEdges x) . uncurry Tri.voroniDiagramCorners) . map ((\x -> drawVoronoiRegion x <> overlayEdges x) . uncurry Tri.voronoiDiagramCorners)
$ voroni $ voronoi
where where
overlayEdges = overlayEdges =
lw (local 0.001) lw (local 0.001)
@ -63,9 +63,9 @@ genImage image dimensionsVec minDistance gen =
. strokeLocLoop . strokeLocLoop
. fromVertices . fromVertices
drawVoroniRegion shape = drawVoronoiRegion shape =
lw 0 lw 0
. fillColor (Tri.voroniRegionAverageColor image dimensions shape) . fillColor (Tri.voronoiRegionAverageColor image dimensions shape)
. strokeLocLoop . strokeLocLoop
. fromVertices . fromVertices
$ shape $ shape
@ -76,9 +76,9 @@ genImage image dimensionsVec minDistance gen =
dimensions :: (Int, Int) dimensions :: (Int, Int)
dimensions = (ceiling $ dimensionsVec ^. _x, ceiling $ dimensionsVec ^. _y) 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 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) sortOnAngle center = sortOn (normalizeAngle . signedAngleBetweenDirs xDir . dirBetween center)
voroniDiagramCorners :: (RealFloat n) => Point V2 n -> [Point V2 n] -> [Point V2 n] voronoiDiagramCorners :: (RealFloat n) => Point V2 n -> [Point V2 n] -> [Point V2 n]
voroniDiagramCorners center midpoints = voronoiDiagramCorners center midpoints =
sortOnAngle center sortOnAngle center
. filter isValidMidpoint . filter isValidMidpoint
. concat . concat
@ -155,8 +155,8 @@ nClosestPoints n p =
. takeSortOn n (abs . distanceA p) . takeSortOn n (abs . distanceA p)
. filter (/= p) . filter (/= p)
findVoroniDiagram :: (RealFloat n) => [(Point V2 n, Point V2 n)] -> [(Point V2 n, [Point V2 n])] findVoronoiDiagram :: (RealFloat n) => [(Point V2 n, Point V2 n)] -> [(Point V2 n, [Point V2 n])]
findVoroniDiagram = findVoronoiDiagram =
M.toList M.toList
. M.mapWithKey . M.mapWithKey
( \key -> ( \key ->
@ -204,8 +204,8 @@ blendEqually colors = C.affineCombo (map (fraction,) colors) C.white
where where
fraction = 1.0 / (fromIntegral . length $ colors) 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 voronoiRegionAverageColor :: (Integral a, Integral b) => Ma.Image Ma.S (Co.SRGB 'Co.Linear) Double -> (a, b) -> [P2 Double] -> Colour Double
voroniRegionAverageColor image (x', y') = voronoiRegionAverageColor image (x', y') =
blendEqually blendEqually
. concatMap (getColorsInTriangle image (x', y')) . concatMap (getColorsInTriangle image (x', y'))
. filter ((== 3) . S.size) . filter ((== 3) . S.size)