3 This file is part of adg-lua.
4 Copyright (C) 2012-2013 Nicola Fontana <ntd at entidi.it>
6 adg-lua is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License, or (at your option) any later version.
11 adg-lua is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General
17 Public License along with adg-lua; if not, write to the Free
18 Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
24 local lgi
= require
'lgi'
25 local Adg
= lgi
.require
'Adg'
26 local Piston
= require
'piston'
29 -- Command line parsing
30 -----------------------------------------------------------------
34 for n
, s
in ipairs(arg
) do
35 -- Arguments are expected in k=v tuples
36 local k
, v
= s
:match('(.-)=(.*)')
37 if not k
then error('Invalid argument ' .. n
) end
41 -- Provide fallback values
69 TITLE
= 'SAMPLE DRAWING',
72 DATE
= os
.date('%d/%m/%Y'),
74 if not request
[k
] then request
[k
] = v
end
79 -----------------------------------------------------------------
81 local piston
= Piston
.new(request
)
85 -----------------------------------------------------------------
88 local canvas
= piston
.view
.detailed
89 canvas
:set_size_explicit(request
.width
or 800, request
.height
or 600)
90 canvas
:set_top_margin(10)
91 canvas
:set_bottom_margin(10)
92 canvas
:set_left_margin(10)
93 canvas
:set_right_margin(10)
100 -----------------------------------------------------------------
102 local _
, err
= canvas
:export('/dev/stdout', 'png')
103 if err
then error(err
) end