-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subdiagram Improvements #113
Comments
Okay, looking at the first example in their tutorial dia1 = (square 1 # translateY 4 # named "bob" ||| circle 1 # named "joe")
# connect "bob" "joe"
dia2 = (square 1 # named "bob" # translateY 4 ||| circle 1 # named "joe")
# connect "bob" "joe"
example :: Diagram B
example = hsep 2 [dia1, dia2] I see that our implementation has a different behaviour: from chalk import *
dia1 = square(1).translate(0, -4).named("bob") | circle(1).named("joe")
dia1 = dia1.connect("bob", "joe")
dia2 = square(1).named("bob").translate(0, -4) | circle(1).named("joe")
dia2 = dia2.connect("bob", "joe")
dia = hcat([dia1, dia2], sep=2) I'll need to check what's going on. |
This seems very subtle. At first read I had it backwards in my head what the behavior would be. It's quite counter intuitive to me that square 1 # translateY 4 # named "bob" Would connect to the old value? Is it because of the way their semantics work? It seems from their hierarchy names propagate like style. https://hackage.haskell.org/package/diagrams-core-1.5.0.1/docs/Diagrams-Core-Types.html#g:4 |
Oh I see the problem. We are using Proposal:
(Not sure what to do about envelope. Maybe you just get access to the transformed version of that. Might be useful to know the radius of the subfigure as presented in the final diagram? But should it be located from the subdiagram origin or the current diagram origin.) Edit: Sometimes Haskell is so clear. The envelope of the a subdiagram is what we were returning. We should just do the same thing in Subdiagram. instance (OrderedField n, Metric v, Monoid' m)
=> Enveloped (Subdiagram b v n m) where
getEnvelope (Subdiagram d a) = transform (transfFromAnnot a) $ getEnvelope d
instance (OrderedField n, Metric v, Semigroup m)
=> Traced (Subdiagram b v n m) where
getTrace (Subdiagram d a) = transform (transfFromAnnot a) $ getTrace d
instance (Metric v, OrderedField n)
=> HasOrigin (Subdiagram b v n m) where
moveOriginTo = translate . (origin .-.)
instance Transformable (Subdiagram b v n m) where
transform t (Subdiagram d a) = Subdiagram d (transfToAnnot t <> a)
-- | Get the location of a subdiagram; that is, the location of its
-- local origin /with respect to/ the vector space of its parent
-- diagram. In other words, the point where its local origin
-- \"ended up\".
location :: (Additive v, Num n) => Subdiagram b v n m -> Point v n
location (Subdiagram _ a) = transform (transfFromAnnot a) origin |
Thanks a lot for the outline! That was super helpful! I was also confused by the behaviour in that particular example, but you were of course right it was related to the local origin of the diagram. Works as expected after implementing the suggested changes. I'll move on to the next features. |
Random project that uses the new with_names and subdiagram features. https://mobile.twitter.com/srush_nlp/status/1587143608121057285 |
As always, an amazing project! 🙂 Very addictive puzzles and beautiful illustrations! Well done! In terms of the drawing API, as far as I can tell you had to resort to the more low-level primitives (that is, |
Oh good question. Let me think:
Crazier ideas:
|
Thanks for sharing these ideas!
Yes, I've seen that
Forgive my ignorance, but what does "Z-space" mean here? |
Oh just like "order" - what is in front and behind. |
Got it, thanks! |
One more potential enhancement idea from Sasha:
|
Subdiagrams come up a lot more than I thought. But it is a little awkward to work with these at the low level. There are a couple of nice functions (locations, with_name, qualification) that we could add.
https://diagrams.github.io/doc/manual.html#named-subdiagrams
Relatedly, I would like to be able to have text positioned above an arrow. Not sure the best way to do this, but maybe there is some way to place named control points.
The text was updated successfully, but these errors were encountered: