Skip to content

Commit

Permalink
refactor delayedLeaf
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyrosenbluth committed Mar 29, 2014
1 parent f61a0bd commit 35576e3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Diagrams/TwoD/Arrow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ arrow' opts len = mkQD' (DelayedLeaf delayedArrow)
-- between which we need to draw the shaft do not transform
-- uniformly as the transformation applied to the entire arrow.
-- See https://github.com/diagrams/diagrams-lib/issues/112.
delayedArrow da =
delayedArrow da g n =
let (trans, globalSty) = option mempty untangle . fst $ da
in dArrow globalSty trans len
in dArrow globalSty trans len g n

-- Build an arrow and set its endpoints to the image under tr of origin and (len,0).
dArrow sty tr ln = (h' <> t' <> shaft)
dArrow sty tr ln gToO nToO = (h' <> t' <> shaft)
# moveOriginBy (tWidth *^ (unit_X # rotate tAngle))
# rotate (direction (q .-. p) ^-^ dir)
# moveTo p
Expand All @@ -475,14 +475,14 @@ arrow' opts len = mkQD' (DelayedLeaf delayedArrow)
hSize = case fromMaybe (Output 20) (getHeadSize <$> getAttr sty) of
Output x -> x
Local x -> x
Normalized x -> x
Global x -> x
Normalized x -> nToO * x
Global x -> gToO * x

tSize = case fromMaybe (Output 20) (getTailSize <$> getAttr sty) of
Output x -> x
Local x -> x
Normalized x -> x
Global x -> x
Normalized x -> nToO * x
Global x -> gToO * x

-- Make the head and tail and save their widths.
(h, hWidth') = mkHead hSize opts'
Expand Down

3 comments on commit 35576e3

@byorgey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Does it work as expected?

@jeffreyrosenbluth
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell it does. But it definitely should be tested more.
It's easy to be fooled into thinking things are the right size when they are not.
Give it a try when you get a chance.

I just added some convenience functions to make headSize and tailSize easier to apply, similar in spirit to lw.

@byorgey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll give it a try later tonight (my time). I'm about to head out for some dinner and a choir concert.

Please sign in to comment.