Haskell Diagrams double lined arrows

465 views Asked by At

I'm working now on my library for Bachelor thesis and I need Your help for making new line type. Bellow there is code for single line, double head arrow: <-> . I would like to ask if there is ability to make from line (line = trailFromOffsets [unitX]) to doubleline, which looks like this: =, and arrow with it looks like this <=> ? If there is ability to make it I would be very thankful for an example! Thank You in advance!

line = trailFromOffsets [unitX]
doubleHeadArrow  = (with & arrowHead  .~ spike & headColor .~ black & headSize .~ 0.4
                         & arrowTail .~ spike' & tailColor  .~ black & tailSize .~ 0.4
                         & arrowShaft .~ line) 
1

There are 1 answers

0
grwp On

I think you need to create some kind of fake arrow. Taking a double headed arrow with an invisble shaft, with opacity of 0. And put two parallel lines to the invisible shaft, so the arrow, using sep.

import Data.Colour (withOpacity)

invisibleShaftArrow = arrowBetween' (with & arrowHead  .~ spike & headColor .~ black & headSize .~ 0.4
                     & arrowTail .~ spike' & tailColor  .~ black & tailSize .~ 0.4
                     & arrowShaft .~ line & shaftColor .~ anyColor `withOpacity` 0)

Edit: More correct, the lines function should do the trick:

line = trailFromOffsets [unitX]
lines = mconcat $ map strokeLocTrail [line, offsetTrail 0.1 line]

example = (with & arrowHead  .~ spike & headColor .~ black & headSize .~ 0.4
                & arrowTail .~ spike' & tailColor  .~ black & tailSize .~ 0.4
                & arrowShaft .~ lines)