voronoi spelling fix
This commit is contained in:
parent
3b9d72b5e5
commit
f7fca3fce3
2 changed files with 12 additions and 12 deletions
12
src/Main.hs
12
src/Main.hs
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue