lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

(Small modification in previous example)

20/10/2010 10:37, Hakki Dogusan wrote:
Hi,
[snip]


Will something like as follows work for you?

-------------------------------------------------------------------------

-- cairo_path_t *path;
-- cairo_path_data_t *data;

local path = cairo.copy_path (cr);

local i = 0
local numdata = cairo.path_num_data(path)

while i < numdata do
    -- data = &path->data[i];
    local headertype = cairo.path_data_header_type(path, i)

    if headertype == CAIRO.PATH_MOVE_TO then

        local x,y = cairo.path_data_point(path, i, 1)

        do_move_to_things (x, y);

    elseif headertype == CAIRO.PATH_LINE_TO then

        local x,y = cairo.path_data_point(path, i, 1)

        do_line_to_things (x, y);

    elseif headertype == CAIRO.PATH_CURVE_TO then

        local x1,y1 = cairo.path_data_point(path, i, 1)
        local x2,y2 = cairo.path_data_point(path, i, 2)
        local x3,y3 = cairo.path_data_point(path, i, 3)

        do_curve_to_things (x1, y1, x2, y2, x3, y3);

    elseif headertype == CAIRO.PATH_CLOSE_PATH then

        do_close_path_things ();

    end

    local headerlength = cairo.path_data_header_length(path, i)
    i = i + headerlength
end

cairo.path_destroy (path);

-------------------------------------------------------------------------

--
Regards,
Hakki Dogusan