Revert "Drop chiphunk dependency. It has moved to a separate package."

This reverts commit 0a06a1efa5 [formerly 2d97e91785c83898269f018a0d109f1340130c35].


Former-commit-id: 633076f6189d8131a9cb9a55a2b81c40dd3a99b8
This commit is contained in:
David Himmelstrup 2020-06-03 14:42:58 +08:00
commit 0f9e200b9e
3 changed files with 16 additions and 14 deletions

View file

@ -95,6 +95,7 @@ library
Reanimate.Builtin.Slide Reanimate.Builtin.Slide
Reanimate.Constants Reanimate.Constants
Reanimate.Parameters Reanimate.Parameters
Reanimate.Chiphunk
Reanimate.PolyShape Reanimate.PolyShape
Reanimate.GeoProjection Reanimate.GeoProjection
Reanimate.Builtin.Documentation Reanimate.Builtin.Documentation
@ -114,7 +115,7 @@ library
cubicbezier, websockets >= 0.12.7.0, cubicbezier, websockets >= 0.12.7.0,
hashable, fsnotify, open-browser, random, random-shuffle, base64-bytestring, hashable, fsnotify, open-browser, random, random-shuffle, base64-bytestring,
vector >= 0.12.0.0, colour, cassava, ansi-wl-pprint, here, temporary, vector >= 0.12.0.0, colour, cassava, ansi-wl-pprint, here, temporary,
optparse-applicative, optparse-applicative, chiphunk >= 0.1.2.1,
geojson, aeson >= 1.3.0.0, geojson, aeson >= 1.3.0.0,
split, fingertree, array, cereal, vector-space split, fingertree, array, cereal, vector-space
if flag(hmatrix) { if flag(hmatrix) {

View file

@ -32,6 +32,7 @@ module Reanimate.PolyShape
, plGroupTouching , plGroupTouching
) where ) where
import Chiphunk.Low
import Control.Lens ((&), (.~)) import Control.Lens ((&), (.~))
import Data.AdditiveGroup import Data.AdditiveGroup
import Data.List (minimumBy, nub, partition, sortOn) import Data.List (minimumBy, nub, partition, sortOn)
@ -88,9 +89,9 @@ plLength = sum . map cubicLength . plCurves
cubicLength c = arcLength c 1 polyShapeTolerance cubicLength c = arcLength c 1 polyShapeTolerance
plArea :: PolyShape -> Double plArea :: PolyShape -> Double
plArea _pl = error "plArea is undefined" -- areaForPoly (map toVect $ plPolygonify polyShapeTolerance pl) 0 plArea pl = areaForPoly (map toVect $ plPolygonify polyShapeTolerance pl) 0
-- where where
-- toVect (Point x y) = Vect x y toVect (Point x y) = Vect x y
-- 1/10th of a pixel if rendered at 2560x1440 -- 1/10th of a pixel if rendered at 2560x1440
polyShapeTolerance :: Double polyShapeTolerance :: Double
@ -206,14 +207,14 @@ plDecompose' tol =
unionPolyShapes unionPolyShapes
decomposePolygon :: [Point Double] -> [[RPoint]] decomposePolygon :: [Point Double] -> [[RPoint]]
decomposePolygon _poly = error "decomposePolygon is undefined" decomposePolygon poly =
-- map (map fromVect . adjust) $ convexDecomposition (map toVect poly) tol map (map fromVect . adjust) $ convexDecomposition (map toVect poly) tol
-- where where
-- tol = polyShapeTolerance tol = polyShapeTolerance
-- toVect (Point x y) = Vect x y toVect (Point x y) = Vect x y
-- fromVect (Vect x y) = V2 x y fromVect (Vect x y) = V2 x y
-- adjust [] = [] adjust [] = []
-- adjust x = if head x == last x then adjust (init x) else x adjust x = if head x == last x then adjust (init x) else x
plPolygonify :: Double -> PolyShape -> [Point Double] plPolygonify :: Double -> PolyShape -> [Point Double]
plPolygonify tol shape = plPolygonify tol shape =

View file

@ -237,8 +237,8 @@ vectorize = vectorize_ []
-- | Same as 'vectorize' but takes a list of arguments for 'potrace'. -- | Same as 'vectorize' but takes a list of arguments for 'potrace'.
vectorize_ :: [String] -> FilePath -> SVG vectorize_ :: [String] -> FilePath -> SVG
vectorize_ _ path | pNoExternals = mkText $ T.pack path vectorize_ _ path | pNoExternals = mkText $ T.pack path
vectorize_ args path = unsafePerformIO $ do vectorize_ args path = unsafePerformIO $ do
root <- getXdgDirectory XdgCache "reanimate" root <- getXdgDirectory XdgCache "reanimate"
createDirectoryIfMissing True root createDirectoryIfMissing True root
let svgPath = root </> show key <.> "svg" let svgPath = root </> show key <.> "svg"