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
|
\startenvironment leaflet-common
%D Please don't abuse this style for your own purpose as the look and feel
%D is reserved for our own purpose. Be creative instead.
\usemodule
[abbreviations-logos]
\setupbodyfont
[plex,12pt]
\setuplayout
[page]
\setupalign
[verytolerant,stretch]
\startluacode
function document.graphic()
local min, max, random, round = math.min, math.max, math.random, math.round
local width = 210
local height = 297
local r, g, b = 3, 3, 3
local bitmap = graphics.bitmaps.new(width,height,"rgb",1)
local data = bitmap.data
local graphic = tonumber(documentdata.variable("graphic"))
if graphic == 1 then
r, g, b = 4, 3, 2
elseif graphic == 2 then
r, g, b = 2, 3, 4
end
for i=1,height do
local d = data[i]
for j=1,width do
local c = random(128,255)
-- d[j] = { 0, 0, c }
d[j] = { c//r, c//g, c//b }
end
end
graphics.bitmaps.tocontext(bitmap,"210bp","297bp")
end
\stopluacode
\definelayer
[page]
[width=\paperwidth,
height=\paperheight]
\setupcolors
[textcolor=white]
\setupbackgrounds
[page]
[background=page]
\setupmakeup
[page]
[style=\bf,
top=,
bottom=]
\startsetups document:start
\setlayerframed
[page]
[offset=overlay]
{\scale
[width=\textwidth,
height=\textheight]
{\ctxlua{document.graphic()}}}
\stopsetups
\stopenvironment
|