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
|
. 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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue