colo-run.lua /size: 2214 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['colo-run'] = {
2    version   = 1.000,
3    comment   = "companion to colo-run.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9-- For historic reasons the core has a couple of tracing features. Nowadays
10-- these would end up in modules.
11
12local utilities = utilities
13local commands  = commands
14local context   = context
15local colors    = attributes.colors
16
17local private   = table.tohash { "c_o_l_o_r", "maintextcolor", "themaintextcolor" }
18
19function commands.showcolorset(name)
20    local set = colors.setlist(name)
21    context.starttabulate { "|l|l|l|l|l|l|l|" }
22    for i=1,#set do
23        local s = set[i]
24        if not private[s] then
25            local r = { width = "4em", height = "max", depth = "max", color = s }
26            context.NC()
27            context.setcolormodel { "gray" }
28            context.blackrule(r)
29            context.NC()
30            context.blackrule(r)
31            context.NC()
32            context.grayvalue(s)
33            context.NC()
34            context.colorvalue(s)
35            context.NC()
36            context(s)
37            context.NC()
38            context.NR()
39        end
40    end
41    context.stoptabulate()
42end
43
44function commands.showcolorcomponents(list)
45    local set = utilities.parsers.settings_to_array(list)
46    context.starttabulate { "|lT|lT|lT|lT|" }
47        context.NC()
48        context("color")
49        context.NC()
50        context("name")
51        context.NC()
52        context("transparency")
53        context.NC()
54        context("specification ")
55        context.NC()
56        context.NR()
57        context.TB()
58        for i=1,#set do
59            local s = set[i]
60            if not private[s] then
61                context.NC()
62                context.showcolorbar { s }
63                context.NC()
64                context(s)
65                context.NC()
66                context.transparencycomponents(s)
67                context.NC()
68                context.colorcomponents(s)
69                context.NC()
70                context.NR()
71            end
72        end
73    context.stoptabulate()
74end
75
76