Skip to content

Commit

Permalink
steps connecting automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrJustyna committed Feb 26, 2024
1 parent 5d43078 commit 6886389
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
28 changes: 8 additions & 20 deletions HelloWorld.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,8 @@
> import Diagrams.Prelude
> import Diagrams.Backend.SVG.CmdLine
>
> myCircle :: Diagram B
> myCircle = circle 1
>
> example :: Diagram B
> example = circle 1 # fc blue
>
> twoCircles :: Diagram B
> twoCircles = circle 1 # fc green ||| circle 1 # fc red
>
> twoShapes :: Diagram B
> twoShapes = square 1 # fc aqua `atop` circle 1
>
> vectorShape :: Diagram B
> vectorShape = fromOffsets . map r2 $ [(0,0), (1,1), (-2,1), (-1,-4)]
>
> stepsOrigins :: [Point V2 Double]
> stepsOrigins = map p2 $ [(x, y) | x <- [0], y <- [0, (-1), (-2)]]
> stepsOrigins = map p2 $ [(x, y) | x <- [0..1], y <- [0, (-1), (-2)]]
>
> step :: Int -> Diagram B
> step x = fromOffsets
Expand All @@ -34,7 +19,10 @@
> # lw veryThin
> # named x
>
> main = mainWith $
> atPoints stepsOrigins [step x | x <- [0..]]
> # connectOutside (0 :: Int) (1 :: Int)
> # connectOutside (1 :: Int) (2 :: Int)
> numberOfSteps :: Int
> numberOfSteps = length stepsOrigins
>
> main =
> mainWith $
> atPoints stepsOrigins [step x | x <- [0 .. ]]
> # applyAll [lw veryThin . connectOutside x (x + 1) | x <- [0 .. numberOfSteps - 2]]
2 changes: 1 addition & 1 deletion hello-world.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6886389

Please sign in to comment.