Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with offset functions #268

Open
JAnthelme opened this issue Jan 21, 2016 · 1 comment
Open

Issue with offset functions #268

JAnthelme opened this issue Jan 21, 2016 · 1 comment

Comments

@JAnthelme
Copy link

I'm on diagrams-lib 1.3.0.9 (Ubuntu Trusty 64bit). Using ghci (ghc version 7.10.2).

When trying to produce an offset from a bézier segment for which the first control point is identical to the first end point (i.e. in the function bezier3 c1 c2 x, using (V2 0.0 0.0) as c1), I get in an "infinite loop" at runtime, resulting in a stack overflow.

In the code below, replacing c1 by (V2 0.0 0.0), instead of (V2 0.0 1.0) for example, produces a run-time error when running main.

{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TypeFamilies              #-}
{-# LANGUAGE FlexibleContexts          #-}

import Diagrams.Backend.SVG
import Diagrams.Prelude

import Diagrams.TwoD.Offset (offsetTrail)

x2      = r2 (1.0,1.0) :: V2 Double    -- endpoint

-- this works well
[c1,c2] = map r2 [(0.0, 1.0), (1.0, 0.0)]    -- control points

-- this creates a run-time error (comment-out line 13, and uncomment line 16 to check).
-- [c1,c2] = map r2 [(0.0, 1.0), (1.0, 0.0)]    -- control points

t   = fromSegments [bézier3 c1 c2 x2]
t'  = (strokeLocTrail $ offsetTrail 0.5 t) # lc orange # lw thick

out = t <> t' # showOrigin

main = do
    let fp   = "./mySVG.svg"
        dims = mkSizeSpec2D (Just (500)) (Just (500))

    renderSVG fp dims (out :: Diagram B)
@byorgey
Copy link
Member

byorgey commented Jan 24, 2016

Thanks for the report! A stack overflow is definitely a bug. I suppose @fryguybob will have to take a look at this, though I think he is deep in paper-writing mode at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants