kuribas / cubicbezier Goto Github PK
View Code? Open in Web Editor NEWHaskell library for manipulating cubic bezier curves
License: BSD 3-Clause "New" or "Revised" License
Haskell library for manipulating cubic bezier curves
License: BSD 3-Clause "New" or "Revised" License
I'd like to implement adaptive bezier subdivision as explained in http://www.antigrain.com/research/adaptive_bezier/index.html. Since I'm new to your library - what's the easiest way to determine if a "curve is flat"?
Preprocessing test suite 'test' for cubicbezier-0.4.0.2...
[1 of 1] Compiling Main ( tests/test.hs, dist/build/test/test-tmp/Main.o )
tests/test.hs:8:1: error:
Failed to load interface for ‘MPTest’
Use -v to see a list of the files searched for.
tests/test.hs:9:1: error:
Failed to load interface for ‘NumTest’
Use -v to see a list of the files searched for.
Geom2D/CubicBezier/Overlap.lhs:279:5: error:
• Variable not in scope:
replicateM_
:: Int
-> SweepStateM ()
-> StateT SweepState Data.Functor.Identity.Identity a0
• Perhaps you meant ‘replicate’ (imported from Prelude)
|
279 | > replicateM_ nR (yStructDel i)
| ^^^^^^^^^^^
Geom2D/CubicBezier/Overlap.lhs:341:40: error:
• Variable not in scope:
liftM2
:: (Ratio Integer -> Ratio Integer -> Ratio Integer)
-> Maybe (Ratio Integer)
-> Maybe (Ratio Integer)
-> Maybe (Ratio Integer)
• Perhaps you meant one of these:
‘lift’ (imported from Control.Monad.State.Strict),
‘liftIO’ (imported from Control.Monad.State.Strict)
|
341 | > | otherwise = set curveRank (liftM2 between
| ^^^^^^
Geom2D/CubicBezier/Overlap.lhs:547:5: error:
Variable not in scope:
unless
:: Bool
-> StateT SweepState Data.Functor.Identity.Identity ()
-> StateT SweepState Data.Functor.Identity.Identity ()
|
547 | > unless (M.null xStr) $ do
| ^^^^^^
Geom2D/CubicBezier/Overlap.lhs:843:5: error:
Variable not in scope:
when
:: Bool
-> StateT SweepState Data.Functor.Identity.Identity ()
-> StateT SweepState Data.Functor.Identity.Identity ()
|
843 | > when (i >= 0 && i < s-1) $
| ^^^^
The affected versions on Hackage are v0.4.0.1, v0.4.0.2, v0.5.0.0, v0.6.0.5 and v0.6.0.6.
As a Hackage trustee I have created Hackage revisions for the affected versions that should prevent users from encountering these errors. See e.g. https://hackage.haskell.org/package/cubicbezier-0.6.0.6/revisions/.
Boolean operations reverse the direction on paths.
If two points are separated by one unit of tolerance on the Y-axis then 'union' will both consider them to be separate (in the X struct) /and/ overlapping. This leads to malformed curves in the output structure and the final output is an empty list.
lhs,rhs :: ClosedPath Double
lhc = ClosedPath
[(Point 2 0,JoinLine)
,(Point 4 3,JoinLine)
,(Point 0 3,JoinLine)]
rhs = ClosedPath
[(Point 2 0.1,JoinLine)
,(Point 6 1,JoinLine)
,(Point 6 3,JoinLine)
]
*Geom2D.CubicBezier.Overlap> union [lhs,rhs] NonZero 0.1
[]
This can be fixed by using (tolerance*2) when creating the X structure.
Geom2D/CubicBezier/MetaPath.hs:71:23: error:
parse error on input ‘-- ^ A metapath with endpoints’
Build failure as seen on the Stackage build server:
Geom2D/CubicBezier/Numeric.hs:218:20: error:
Not in scope: ‘G.unsafeTakeRow’
Perhaps you meant ‘V.unsafeTake’ (imported from Data.Vector.Unboxed)
Module ‘Data.Matrix.Generic’ does not export ‘unsafeTakeRow’.
|
218 | (G.unsafeTakeRow m i)
| ^^^^^^^^^^^^^^^
I was able to reproduce this locally like so:
stack unpack cubicbezier-0.6.0.5 && cd cubicbezier-0.6.0.5
edit stack.yaml # add the following stack.yaml
stack build --test --bench --no-run-benchmarks --fast
# stack.yaml
resolver: nightly-2018-12-20
extra-deps:
- fast-math-1.0.2
- matrices-0.5.0
In one of my algorithms I'm relying heavily on the closest
function from the Geom2D.CubicBezier.Intersection
module. Recently I've stumbled upon a specific use case in which no parameter t
is found, which would mean there was no closest point for the supplied one (I find it to be slightly illogical).
The example data:
> let c = CubicBezier (Point 52.44 122.36) (Point 0 471.95) (Point 506.91 192.28) (Point 349.59 174.8)
> closest c (Point 319 171) 0.001
[]
I've made a fiddle to visualize this specific scenario: http://jsfiddle.net/2Xz6C/
Is there any explanation as to why this is happening? Can this be 'solved' by simply choosing the closest of the end points of the curve or is it more complicated than that?
The latest version on Hackage does not include this commit, which made tests compile. So the Hackage version does not compile for me. Please upload the latest version to Hackage.
Thanks!
See failure below
I've already revised the meta-data of affected releases on Hackage as this was causing transitive failures in a few packages:
Configuring component lib from cubicbezier-0.6.0.2...
Preprocessing library cubicbezier-0.6.0.2...
[ 1 of 12] Compiling Math.BernsteinPoly ( Math/BernsteinPoly.hs, /tmp/matrix-worker/1493131754/dist-newstyle/build/x86_64-linux/ghc-7.8.4/cubicbezier-0.6.0.2/build/Math/BernsteinPoly.o )
[ 2 of 12] Compiling Geom2D.CubicBezier.Numeric ( Geom2D/CubicBezier/Numeric.hs, /tmp/matrix-worker/1493131754/dist-newstyle/build/x86_64-linux/ghc-7.8.4/cubicbezier-0.6.0.2/build/Geom2D/CubicBezier/Numeric.o )
Geom2D/CubicBezier/Numeric.hs:334:34: Warning:
This binding for ‘rows’ shadows the existing binding
imported from ‘Data.Matrix.Unboxed’ at Geom2D/CubicBezier/Numeric.hs:15:1-31
(and originally defined in ‘Data.Matrix.Generic’)
Geom2D/CubicBezier/Numeric.hs:346:17: Warning:
This binding for ‘rows’ shadows the existing binding
imported from ‘Data.Matrix.Unboxed’ at Geom2D/CubicBezier/Numeric.hs:15:1-31
(and originally defined in ‘Data.Matrix.Generic’)
[ 3 of 12] Compiling Geom2D ( Geom2D.hs, /tmp/matrix-worker/1493131754/dist-newstyle/build/x86_64-linux/ghc-7.8.4/cubicbezier-0.6.0.2/build/Geom2D.o )
Geom2D.hs:21:33: Not in scope: type constructor or class ‘Foldable’
Geom2D.hs:21:43:
Not in scope: type constructor or class ‘Traversable’
Geom2D.hs:37:32: Not in scope: type constructor or class ‘Foldable’
Geom2D.hs:37:42:
Not in scope: type constructor or class ‘Traversable’
Geom2D.hs:40:42: Not in scope: type constructor or class ‘Foldable’
Geom2D.hs:40:52:
Not in scope: type constructor or class ‘Traversable’
Geom2D.hs:43:45: Not in scope: type constructor or class ‘Foldable’
Geom2D.hs:43:55:
Not in scope: type constructor or class ‘Traversable’
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.