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 = [[
]]}}
local arcs02 = {type = 'svg', file = {string = [[
]]}}
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())