ADG Lua 

ADG Lua Commit Details

Date:2013-04-01 21:46:38 (6 years 3 months ago)
Author:Nicola Fontana
Branch:master
Commit:013dc759b170b5d2477daee5eecc5e5eb166699a
Parents: 953659302b27581dd5cf6e34b0c931edb0e04a24
Message:adg-web: allow custom size

Adjust the zoom factor (the global map xx and yy components) to get the
(optional) requested size and maintaining the 4/3 ration (800x600).
Changes:
Madg-web.lua (2 diffs)

File differences

adg-web.lua
3232
3333
3434
35
3536
3637
3738
......
9798
9899
99100
100
101
102
103
104
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
105116
106117
107118
local lgi = require 'lgi'
local cairo = lgi.require 'cairo'
local Adg = lgi.require 'Adg'
local Piston = local_require 'piston'
local n = 1
local canvas = piston.view.detailed
canvas:set_size_explicit(request.width or 800, request.height or 600)
canvas:set_top_margin(10)
canvas:set_bottom_margin(10)
canvas:set_left_margin(10)
canvas:set_right_margin(10)
canvas:set_margins(10, 10, 10, 10)
canvas:set_paddings(0, 0, 0, 0)
canvas:set_size_explicit(800, 600)
-- Adjust the zoom factor based on the (optional) requested size
local zoom = 1
if request.width then
local x_zoom = request.width / 800
if x_zoom < zoom then zoom = x_zoom end
end
if request.height then
local y_zoom = request.height / 600
if y_zoom < zoom then zoom = y_zoom end
end
canvas:set_global_map(cairo.Matrix { xx = zoom, yy = zoom })
piston:refresh()
canvas:autoscale()

Archive Download the corresponding diff file

Branches

Tags