leaflet-common.tex /size: 1574 b    last modification: 2020-07-01 14:35
1\startenvironment leaflet-common
2
3%D Please don't abuse this style for your own purpose as the look and feel
4%D is reserved for our own purpose. Be creative instead.
5
6\usemodule
7  [abbreviations-logos]
8
9\setupbodyfont
10  [plex,12pt]
11
12\setuplayout
13  [page]
14
15\setupalign
16  [verytolerant,stretch]
17
18\startluacode
19    function document.graphic()
20        local min, max, random, round = math.min, math.max, math.random, math.round
21
22        local width   = 210
23        local height  = 297
24        local r, g, b = 3, 3, 3
25
26        local bitmap  = graphics.bitmaps.new(width,height,"rgb",1)
27        local data    = bitmap.data
28
29        local graphic = tonumber(documentdata.variable("graphic"))
30
31        if graphic == 1 then
32            r, g, b = 4, 3, 2
33        elseif graphic == 2 then
34            r, g, b = 2, 3, 4
35        end
36
37        for i=1,height do
38            local d = data[i]
39            for j=1,width do
40                local c = random(128,255)
41             -- d[j] = { 0, 0, c }
42                d[j] = { c//r, c//g, c//b }
43            end
44        end
45
46        graphics.bitmaps.tocontext(bitmap,"210bp","297bp")
47    end
48\stopluacode
49
50\definelayer
51  [page]
52  [width=\paperwidth,
53   height=\paperheight]
54
55\setupcolors
56  [textcolor=white]
57
58\setupbackgrounds
59  [page]
60  [background=page]
61
62\setupmakeup
63  [page]
64  [style=\bf,
65   top=,
66   bottom=]
67
68\startsetups document:start
69
70    \setlayerframed
71      [page]
72      [offset=overlay]
73      {\scale
74         [width=\textwidth,
75          height=\textheight]
76         {\ctxlua{document.graphic()}}}
77
78\stopsetups
79
80\stopenvironment
81