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

Is it possible to get ahold of the Drawing? #60

Open
kindaro opened this issue Oct 8, 2019 · 1 comment
Open

Is it possible to get ahold of the Drawing? #60

kindaro opened this issue Oct 8, 2019 · 1 comment

Comments

@kindaro
Copy link

kindaro commented Oct 8, 2019

So there is this issue elsewhere Twinside/Rasterific#53 and I need to provide some debug output which in turn requires me to feed in a Drawing type thing. I am not sure how to go about rendering my diagram to that type. It seems that renderDia can only give me an Image, which is a later stage of the diagram's lifeline.

@byorgey
Copy link
Member

byorgey commented Oct 9, 2019

So unfortunately there is no really easy way to do this. The definition of renderRTree for the Backend Rasterific instance compiles the diagram to a Drawing and then immediately renders it without ever giving access to the intermediate result. You can see the code here:

https://github.com/diagrams/diagrams-rasterific/blob/master/src/Diagrams/Backend/Rasterific.hs#L182

One solution would be to manually call the part of the definition up to the Drawing, but this is a bit complicated by the fact that you would have to manually compose it with the other things the generic renderDia is doing (rescaling, centering, etc. --- see https://github.com/diagrams/diagrams-core/blob/master/src/Diagrams/Core/Compile.hs#L188) to get all the coordinates to come out right . Another option, but also annoying, would be to copy the entirety of Diagrams.Backend.Rasterific and modify the Backend instance to have type Result Rasterific V2 n = (Image PixelRGBA8, Drawing) or something like that. Then modify the renderRTree method to return a pair, like (R.renderDrawing (round w) (round h) bgColor r, r).

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

No branches or pull requests

2 participants