[cairo] Question about LuaCairo and wxLua

W Wlourf wlourf1 at yahoo.com
Sat Nov 5 03:53:14 PDT 2011


Hello,


Is it possible to use LuaCairo with wxLua. I've seen CairoPad but I can't get it works on my computer (Debian Squeeze). 


What sould I change to this code to display the cairo context on the screen :



package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"

require("wx")
local Cairo = require("lcairo")

mainWin = wx.wxFrame(wx.NULL, -1,"Hello Shao",wx.wxPoint(100,100),wx.wxSize(500,500))
 
function OnPaint(event)
        local dc = wx.wxPaintDC(mainWin) 
        local cs = Cairo.image_surface_create(Cairo.FORMAT_ARGB32, 250,250)
        print ("cs",cs)
        --doesn't work
        --local cr = Cairo.CreateContext(wx.get_drawable(dc)) --HACK!   
        local cr = Cairo.Context(cs)
        print ("cr", cr)
        
        cr:push_group_with_content(Cairo.CONTENT_COLOR)
        cr:set_source_rgb (0, 0, 1)
        cr:paint ()
        cr:set_source_rgba(0,1,0,1)
        cr:rectangle(0, 0, 100, 100)
        cr:fill()
        cr:pop_group_to_source()
        Cairo.surface_write_to_png(cs,"/tmp/test.png") -->ok if not push/pop group
        dc:DrawRectangle(100,100,100,100) -->ok
        dc:delete()

end
 
mainWin:Connect(wx.wxEVT_PAINT, OnPaint)
 
mainWin:Show(true)
wx.wxGetApp():MainLoop()


Thanks in advance


PS : Hakki, if you read me, why your Hack wx.get_drawable(dc) doesn't work ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20111105/d7690cab/attachment.htm>


More information about the cairo mailing list