Open jamesdbrock opened 3 years ago
Hi @jamesdbrock , that sounds like a cool idea!
So the way the Turtle library works is by accumulating a state which describes the paths that the turtle has drawn, their styles, etc. Then at the end you can render a Turtle state into a Diagram. (Take a look at Diagrams.TwoD.Path.Turtle.Internal
.) In order to implement stamp
you would have to add something to the Turtle state, which could just be a list of Diagrams. Every time stamp
is called you add an (appropriately translated and rotated) diagram to the list. Then when doing the final render of a Turtle state into a Diagram you can just use mconcat
to add in all those diagrams. There's probably some tricky issues to figure out in terms of what gets drawn on top of what, but I think this should be doable.
you would have to add something to the Turtle state
Ah, yes, I see that now, thanks for pointing that out.
Maybe we could change the type of paths
to be
data TurtleState n = TurtleState
{ ...
, paths :: [Either (TurtlePath n) (Located (QDiagram b V2 n Any ))]
}
Yes, that makes sense. Although there's no need to use Located QDiagram
---just QDiagram
will suffice since diagrams are already inherently located.
Hi, thanks for this library @mgsloan , it's really great!
I want a function which enables the turtle to render any diagram at its current location, with its current orientation.
I would call this function
stamp
, like the idea of using a rubber ink stamp on paper.I think the
stamp
function should have this type signature?I'm going to try to write this
stamp
function. Do you know if anyone else has ever written it? Do you have any advice for writing it?Reference: http://hackage.haskell.org/package/diagrams-contrib-1.4.4/docs/Diagrams-TwoD-Path-Turtle.html
Possibly related: #5