Closed bacchanalia closed 5 years ago
hold off, I think there's another bug in my pr.
pr fixed
I refactored splitAtParam'. Going to work on tests next. In the meantime I would appreciate if someone would take a look at the last commit and code below and tell me if you have any ideas why the magenta and darkmagenta arcs don't line up with their tick marks.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine
type T = Located (Trail V2 Double)
δ = 1/10
ex :: Diagram Cairo
ex = mconcat $ (zipWith ($)
-- over/under
[ \r -> stroke (circle r :: T)
, \r -> ((stroke (section ((!! 1) $ fixTrail (circle r :: T)) (0 - δ) 1) # lc blue)
<> (stroke (section ((!! 2) $ fixTrail (circle r :: T)) 0 (1 + δ)) # lc green ))
, \r -> stroke (section (circle r :: T) ((1 - δ)/4) ((3 + δ)/4)) # lc red
, \r -> stroke (section (unfixTrail . drop 1 . fixTrail $ circle r :: T) ((0 - δ)/3) ((2 + δ)/3)) # lc blue
, \r -> stroke (section (unfixTrail . take 3 . fixTrail $ circle r :: T) ((1 - δ)/3) ((3 + δ)/3)) # lc green
, \r -> (stroke (p2 (103, 0) ~~ p2 (r-3, 0) :: T)) # rotate (((1 - δ)/4) @@ turn)
<> (stroke (p2 (103, 0) ~~ p2 (r-3, 0) :: T)) # rotate (((3 + δ)/4) @@ turn)
-- same seg
, \r -> (stroke (section (circle r :: T) (5/16) (7/16)) # lc magenta)
<> ((stroke (p2 (r-2, 0) ~~ p2 (r+2, 0) :: T)) # rotate ((5/16) @@ turn))
<> ((stroke (p2 (r-2, 0) ~~ p2 (r+2, 0) :: T)) # rotate ((7/16) @@ turn))
-- tSegs /= tSegs'
, \r -> (stroke (section (circle r :: T) (7/16) (9/16)) # lc darkmagenta)
<> ((stroke (p2 (r-2, 0) ~~ p2 (r+2, 0) :: T)) # rotate ((7/16) @@ turn))
<> ((stroke (p2 (r-2, 0) ~~ p2 (r+2, 0) :: T)) # rotate ((9/16) @@ turn))
] [100,105..])
dia :: Diagram Cairo
dia = (ex # pad 1.1)
main = mainWith (dia # bg white)
This should be ready to merge unless we want to investigate the discrepancy in my previous comment or we want to change the story about Sectionable for Trail' Loop, but that could be it's own PR.
I'm investigating something. Not sure wether it's in this code or the code I'm calling this from.
Looks good to me. Re: the ends of arcs not exactly lining up with their tick marks (is that still an issue?) I'm not sure, but we can address that separately.
section on trail producing incorrect result when upper param is
The first parameter was not being rescaled properly in the case that the second parameter was >= 1. The old code tried to rescale as though an extra segment was added, while what the code actually does is replace the last segment with a longer one. This leads two two cases, either the first param is on a previous segment and doesn't need to change or it's on the last segment and has to be rescaled to the new length.