Skip to content
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

Measured diagrams #246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Measured diagrams #246

wants to merge 1 commit into from

Conversation

cchalmers
Copy link
Member

Not ready to merge yet. Closes #208.

Function for turning a Measured (Diagram b) into a Diagram b by putting it in a DelayedLeaf. This means you can make diagrams using normalized, output etc. without having to manually deal with DelayedLeaf and DownAnnots.

outputCircle = fc blue . circle <$> output 30 :: MDiagram Rasterific
sq = square 2 <> measuredDiagram outputCircle :: Diagram Rasterific
frame 0.1 $ sq # scale 2 ||| sq

example

Measured already has the HasStyle, Juxtaposable and friends instances. I'm not sure what Transformable should it be fmap (transform t) or scaling it so only local units get scaled?

@byorgey
Copy link
Member

byorgey commented Sep 12, 2015

What's the status of this? Is it just that we still aren't sure about the Transformable instance? If so, can you explain a bit more what the issue is?

@cchalmers
Copy link
Member Author

To be honest I just forgot about.

Concerning the Transformable instance the options are just fmap the transform:

instance Transformable t => Transformable (Measured t) where
  transform t = fmap (transform t)

or do something similar to how Text gets transformed so only local measures get scaled from transforms. Something like

instance Transformable t =>  Transformable (Measured t) where
  transform t = scaleLocal n . fmap (transform t')
    where
      t' = t <> scaling (1 / avgScale t)
      n = avgScale t

but I'm not sure how much sense this option makes.

Other than that I just need to document it and it should be ready to merge.

@byorgey
Copy link
Member

byorgey commented Sep 12, 2015

So to be clear, under the two different options for Transformable, if you e.g. created a measured circle of size output 30 and then scaled it by 2, what would happen?

@cchalmers
Copy link
Member Author

Under the first option the circle would double in size. In the second option nothing would change (but if it was a measured circle of size local 30, that would double in size).

@byorgey
Copy link
Member

byorgey commented Sep 12, 2015

I see. I think I would expect the latter. The former seems very strange and not that useful. What does output 30 even mean if you can change it by scaling? Under that first instance, if you wanted a diagram to have a particular size in the output you would either have to (1) avoid scaling it at all, or (2) compute what "output size" you should specify so that after scaling it will have the real output size you actually want.

@byorgey
Copy link
Member

byorgey commented Sep 12, 2015

Why don't you think the second instance makes sense?

@cchalmers
Copy link
Member Author

Just because it's something I came up with now, I haven't tested it. I'll try implementing it make sure it does what I think it does (I'm not sure about translations for example). I agree, if the second option does work it should be the one we use.

@cchalmers
Copy link
Member Author

I guess what I want is

transform t (measuredDiagram md) == measuredDiagram (transform t md)

where md :: Measured n (Diagram b v n).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Measures anywhere
2 participants