local glue = require'glue' local cairo = require'cairo' --require'scenegraph.cairopng' local winapi = require'winapi' require'winapi.windowclass' local CairoSGPanel = require'winapi.cairosgpanel' local main = winapi.Window{ autoquit = true, visible = false, title = cairo.version_string(), } local panel = CairoSGPanel{ parent = main, anchors = {left=true,right=true,top=true,bottom=true}, w = main.client_w, h = main.client_h, } local function dir(d) local f = io.popen('ls -1 '..d) return glue.collect(f:lines()) end local files = dir'media/svg/*.svg' local i = 133 --77, 87, 119, 133 (leon) local marker = {type = 'shape', path = {'rect', 0, 0, 100, 100}, stroke = {type = 'color', 0, 0, 0}} --pp(#bpath) local arcs01 = {type = 'svg', file = {string = [[ Example arcs01 - arc commands in path data Picture of a pie chart with two pie wedges and a picture of a line with arc blips ]]}} local arcs02 = {type = 'svg', file = {string = [[ Example arcs02 - arc options in paths Pictures showing the result of setting large-arc-flag and sweep-flag to the four possible combinations of 0 and 1. Arc start Arc end large-arc-flag=0 sweep-flag=0 large-arc-flag=0 sweep-flag=1 large-arc-flag=1 sweep-flag=0 large-arc-flag=1 sweep-flag=1 ]]}} local svgfile = {type = 'svg', file = {path = 'media/svg/leon.svg'}} local scene = {type = 'group', x = 600, --y = 100, {type = 'color',1,1,1}, svgfile, {type = 'group', x = -500, arcs01}, {type = 'group', x = -500, y = 300, arcs02}, } local zoom = 1 local stroke_extents_stroke = {type = 'color', 0, 0, 1, 0.5} local fill_extents_stroke = {type = 'color', 1, 0, 0, 0.5} function panel:on_render() scene.scale = zoom self.scene_graph.stroke_extents_stroke = stroke_extents_stroke self.scene_graph.fill_extents_stroke = fill_extents_stroke self.scene_graph:render(scene) self.scene_graph.cache:clear() end function main:on_mouse_wheel(x, y, buttons, delta) zoom = zoom + delta/120/10 panel:invalidate() end --panel:settimer(1000, panel.invalidate) main:show() os.exit(winapi.MessageLoop())