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

Spike arrowhead and tail render with oversized joint #203

Closed
jeffreyrosenbluth opened this issue Jul 22, 2014 · 6 comments
Closed

Spike arrowhead and tail render with oversized joint #203

jeffreyrosenbluth opened this issue Jul 22, 2014 · 6 comments

Comments

@jeffreyrosenbluth
Copy link
Member

I believe this bug was introduced with the direction branch.
Sorry for the code length.

{-# LANGUAGE NoMonomorphismRestriction #-}

import Diagrams.Prelude
import Diagrams.Backend.Rasterific.CmdLine
import Data.List.Split (chunksOf)

-- Create a 3 x 3 grid of circles named "1" to "9"
c = circle 1.5 # fc lightgray # lw none # showOrigin
cs = [c # named (show x) | x <- [1..9]]
cGrid = (vcat' $ with & sep .~ 4)
      . map (hcat' $ with & sep .~ 12)
      . chunksOf 3 $ cs

-- For the Shafts.
semicircle = arc xDir (2/5 @@ turn)
quartercircle = arc xDir (1/4 @@ turn)

parab = bezier3 (1 ^& 1) (1 ^& 1) (0 ^& 2)
parab' = reflectX parab

seg = straight unitX
seg' = seg # rotateBy (1/6)

shaft0 = trailFromSegments [parab, seg, parab', seg, parab]
shaft1 = cubicSpline False (trailVertices (shaft0 `at` origin))
shaft2 = cubicSpline False (map p2 [(0,0), (1,0), (0.8, 0.2),(2, 0.2)])

example :: Diagram B R2
example = connect'        arrow1 "1" "2"
        . connect'        arrow2 "4" "3"
        . connect'        arrow3 "1" "6"
        . connectOutside' arrow4 "4" "8"
        . connect'        arrow5 "9" "5"
        . connectOutside' arrow6 "8" "9"
        . connectOutside' arrow7 "8" "7"
        $ cGrid

  where
    -- The arrows
    arrow1 = with & arrowHead .~ dart 
                  & arrowTail .~ quill & shaftStyle %~ lw thick . lc black
                  & arrowShaft .~ shaft0 & headStyle %~ fc blue
                  & tailStyle %~ fc red & tailLength .~ large

    arrow2 = with & arrowHead .~ dart & headLength .~ large
                  & arrowTail .~ dart' & tailLength .~ large
                  & shaftStyle %~ lw thin & arrowShaft .~ shaft1

    arrow3 = with & arrowHead .~ thorn & headLength .~ large
                  & arrowShaft .~ quartercircle & arrowTail .~ noTail
                  & gaps .~ normal

    arrow4 = with & arrowHead .~ dart & arrowTail .~ dart'
                  & arrowShaft .~ shaft2 & headStyle %~ fc teal
                  & tailStyle %~ fc teal & shaftStyle %~ lw thick . lc teal

    arrow5 = with & arrowTail .~ spike' & tailLength .~ large
                  & arrowShaft .~ semicircle & arrowHead .~ spike
                  & headLength .~ large & headStyle %~ fc darkorange
                  & tailStyle %~ fc darkorange
                  & shaftStyle %~ lw veryThick . lc navy

    arrow6 = with & arrowHead .~ tri & arrowTail .~ tri'
                  & headLength .~ large
                  & headStyle %~ fc black . opacity 0.5
                  & tailStyle %~ fc black . opacity 0.5
                  & shaftStyle %~ dashingN [0.01,0.02,0.03,0.01] 0

    arrow7 = arrow6 & arrowHead .~ tri & arrowTail .~ tri'

main = mainWith $ example # frame 0.2

arrow

@bergey
Copy link
Member

bergey commented Jul 22, 2014

The bug is that the darkorange arrowheads with spike form have the arc part convex instead of concave, right? That does sound like something I would have introduced with Direction. I'll take a look.

@jeffreyrosenbluth
Copy link
Member Author

I believe so, about the concavity. Or it could be something wrong with the joint.

Thanks for looking.

@jeffreyrosenbluth
Copy link
Member Author

There a very small chance that this could be helpful.
geom

bergey added a commit that referenced this issue Jul 23, 2014
bug introduced by changes to Arc to use Direction type
see issue #203
@bergey
Copy link
Member

bergey commented Jul 23, 2014

@jeffreyrosenbluth The commit I just pushed fixes the obvious rendering error in the arrowhead. Thanks for the very helpful diagram; I was confused about what theta meant.

I don't actually understand how joints work. You mention them upthread; maybe the arc in the joint definition needs to change also. Do you want to take a look, or explain what shape the joint should have in reference to the diagram above?

For this reason I haven't closed the issue yet.

@jeffreyrosenbluth
Copy link
Member Author

@bergey
Thanks for fixing it. Let me try to explain how joints work, although it's hard to fake it so if the example above renders correctly it is unlikely that the spike joint is broken.

In the circle on the right in the above diagram the small piece at 1/2 turn shows how the joint is constructed. Call this piece j, then the joint is reflectX (j === relfectY j).
which is attached to the head so that a shaft of line width w attaches to the head without any gap or the need for overlap.

@bergey
Copy link
Member

bergey commented Jul 23, 2014

Thanks for the explanation. That does fit the current definition, so I think this is fixed.

@bergey bergey closed this as completed Jul 23, 2014
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