ADG Lua 

ADG Lua Commit Details

Date:2013-03-28 19:45:45 (6 years 5 months ago)
Author:Nicola Fontana
Branch:master
Commit:8edef1f8b6bdeff0c7bfc9b6619d8ac6a584552d
Parents: 6d61a92b63c57746244b88aacc5ab28d63b9b24a
Message:adg-web: first implementation

This script is yet able to generate a png file with all the data
overridable from the command line.

A typical example could look like this:

lua adg-web.lua A=70 B=15 C=30 > result.png
Changes:
Aadg-web.lua (full)
MMakefile.am (1 diff)

File differences

Makefile.am
1010
1111
1212
13
13
14
15
1416
1517
1618
THANKS \
$(BUILT_SOURCES)
dist_pkgdata_DATA=piston.lua
pkgdata_DATA=adg-demo.lua
dist_pkgdata_DATA=adg-web.lua \
piston.lua
# Creating ChangeLog files from git log:
adg-web.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--[[
This file is part of adg-lua.
Copyright (C) 2012-2013 Nicola Fontana <ntd at entidi.it>
adg-lua is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
adg-lua is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with adg-lua; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
]]
local lgi = require 'lgi'
local Adg = lgi.require 'Adg'
local Piston = require 'piston'
-- Command line parsing
-----------------------------------------------------------------
local request = {}
for n, s in ipairs(arg) do
-- Arguments are expected in k=v tuples
local k, v = s:match('(.-)=(.*)')
if not k then error('Invalid argument ' .. n) end
request[k] = v
end
-- Provide fallback values
for k, v in pairs {
A = 55,
B = 20.6,
C = 2,
DHOLE = 2,
LHOLE = 3,
D1 = 9.3,
D2 = 6.5,
D3 = 13.8,
D4 = 6.5,
D5 = 4.5,
D6 = 7.2,
D7 = 2,
RD34 = 1,
RD56 = 0.2,
LD2 = 7,
LD3 = 3.5,
LD5 = 5,
LD6 = 1,
LD7 = 0.5,
GROOVE = false,
ZGROOVE = 16,
DGROOVE = 8.3,
LGROOVE = 1,
CHAMFER = 0.3,
-- Metadata
TITLE = 'SAMPLE DRAWING',
DRAWING = 'PISTON',
AUTHOR = 'adg-web',
DATE = os.date('%d/%m/%Y'),
} do
if not request[k] then request[k] = v end
end
-- Part definition
-----------------------------------------------------------------
local piston = Piston.new(request)
-- Canvas settings
-----------------------------------------------------------------
local n = 1
local canvas = piston.view.detailed
canvas:set_size_explicit(800 - 20, 600 - 20)
canvas:set_top_margin(10)
canvas:set_bottom_margin(10)
canvas:set_left_margin(10)
canvas:set_right_margin(10)
piston:refresh()
canvas:autoscale()
-- File generation
-----------------------------------------------------------------
local _, err = canvas:export('/dev/stdout', 'png')
if err then error(err) end

Archive Download the corresponding diff file

Branches

Tags