You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was no example, but I had been meaning to get around to this for a while, so I decided to finally write an example. Please see https://github.com/haskell-gi/haskell-gi/blob/master/examples/Cairo.hs , which is a straight port of the cairo-clock example in gtk2hs to haskell-gi (you will need GHC 8.0 to compile this example).
The issue is that there is no useful introspection data in cairo itself, so the haskell-gi bindings are not useful at all in themselves. Luckily one can use the hand-written bindings in the cairo library without much effort. Everything is fairly straightforward, the only tricky part is the following function:
--| This function bridges gi-cairo with the hand-written cairo-- package. It takes a `GI.Cairo.Context` (as it appears in gi-cairo),-- and a `Render` action (as in the cairo lib), and renders the-- `Render` action into the given context.renderWithContext::GI.Cairo.Context->Render()->IO()
renderWithContext ct r = withManagedPtr ct $\p ->
runReaderT (runRender r) (Cairo (castPtr p))
I hope this helps. If anything is confusing please do not hesitate to ask.
Hello,
Thanks for sharing haskell-gi.
Just want to check if there is an example or sample code using haskell-gi to render to a gtk3 window using Cairo.
Thanks
The text was updated successfully, but these errors were encountered: