[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] LuaCairo and CairoPad updated
- From: Hakki Dogusan <dogusanh@...>
- Date: Tue, 18 Nov 2008 02:11:42 +0200
Hi,
Asko Kauppi wrote:
I think with the OO approach one should go strictly with the official
cairomm API.
http://www.cairographics.org/documentation/cairomm/reference/namespaceCairo.html
Anything else would mean one needs to do and maintain heavy
documentation. Also, it will be easier to sell an implementation if it
does not deviate from an existing well designed API.
I agree (especially with documentation part!).. I'll investigate
cairomm' API with a 'Lua user hat' on my head :)
Meanwhile I've finished mentioned Context's implementation.
http://www.dynaset.org/dogusanh/download/luacairo-1.8.4.1-src.zip (43Kib)
Could you check it, please?
Your example becomes as following (also in download, as cairo_test5oo.lua):
---------------------------------------------------------------
local cairo = require"lcairo"
local CAIRO = cairo
local w = 320
local h = 240
local outfile = "cairo_test2.png"
local cs = cairo.image_surface_create(CAIRO.FORMAT_RGB24, w, h)
-- local cr = cairo.create(cs)
-- option:0 when implemented :)
-- local cs = cairo.ImageSurface(CAIRO.FORMAT_RGB24, w, h)
-- local cr = cairo.Context(cs)
-- option:1
-- local crraw = cairo.create(cs)
-- local cr = cairo.Context(crraw, true) -- true:give ownership,
default:false
-- option:2
local cr = cairo.Context()
cr:create(cs)
cr:set_source_rgb(1, 1, 1)
cr:paint()
cr:set_source_rgb(0, 0, 0)
cr:select_font_face("Sans", CAIRO.FONT_SLANT_NORMAL, CAIRO.FONT_WEIGHT_BOLD)
cr:set_font_size(w/6)
cr:move_to(0, h/4)
cr:show_text("Hello cairo!")
cr:select_font_face("Sans", CAIRO.FONT_SLANT_NORMAL,
CAIRO.FONT_WEIGHT_NORMAL)
cr:set_font_size(w/8)
cr:move_to(0, 3*h/4)
cr:text_path("Lua calling...")
cr:set_source_rgb(0.5, 0.5, 1)
cr:fill_preserve()
cr:set_source_rgb(0, 0, 0)
cr:set_line_width(w/200)
cr:stroke()
--not yet! cs:write_to_png(outfile)
cairo.surface_write_to_png(cs, outfile)
-----------------------------------------------------------
-asko
Hakki Dogusan kirjoitti 17.11.2008 kello 18:52:
[snip]
--
Regards,
Hakki Dogusan