-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogo.typ
More file actions
217 lines (203 loc) · 6.71 KB
/
logo.typ
File metadata and controls
217 lines (203 loc) · 6.71 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#import "@preview/fletcher:0.5.7": *
#let circular-bend(x, y) = {
let R = (x*x + y*y) / (2*y);
let tanTheta = x / (R - y);
calc.atan(tanTheta)
}
/// create a single-page LDMX logo
///
/// text-color: type color, default white, color of all text objects in logo
/// bkgd-color: type color, default black, background color of logo
/// electron-color: type color, default to text-color, color of electron "beam" in logo
/// electron-ls: typ str, default to "-", line style for electron (e.g. solid is "-", dashed "--", dotted "..")
/// dm-color: type color, default to bkgd-color, color of produced DM tracks in logo
/// dm-text-color: type color, default to text-color, color of the letters D and M in LDMX in logo
/// prefix: extra text to include in front of LDMX
/// suffix: extra text to be included after LDMX
/// un: for adding "un" in LunDMX above horizontal bar of the L
/// page-args: how to construct the page around the logo, default is no page
/// none or auto makes the page the same size and shape as the logo
/// "square" makes the page a square with the side length determined by the width of the logo
/// a dictionary is provided directly to `set page` before displaying the logo for customization
///
/// For prefix and suffix, if a string is provided, then some default formatting
/// is applied. You can customize this formatting by providing the content yourself
/// (like is done with the SW suffix in the ldmx-sw variation).
/// The default formatting for the prefix is 16pt font with light weight aligned
/// to the top so it is over the incoming beam (like in the umn and mini variations).
/// The default formatting for the suffix is 16pt font with light weight aligned
/// to the bottom.
#let logo(
text-color: white,
bkgd-color: black,
electron-color: auto,
electron-ls: "-",
dm-color: auto,
dm-text-color: auto,
prefix: none,
suffix: none,
un: none,
page-args: auto
) = context {
// default dm color to bkgd color so that it "disappears"
let dm-color = if dm-color == auto {
bkgd-color
} else { dm-color }
// default DM text color to text color
let dm-text-color = if dm-text-color == auto {
text-color
} else { dm-text-color }
// default electron color to text color
let electron-color = if electron-color == auto {
text-color
} else { electron-color }
set text(font: "Aileron", fill: text-color)
// requires context in order to deduce size of text
let text-box-height = measure(text(size: 32pt)[L]).height
// other magic numbers I fiddle with to get the placements correct
// shift of target point relative to the letter L so that the target
// is in the vertical bar of the L
// depends on the font and size
let target-shift = (-0.45em, 0em)
// point that electron should stop relative to target
// ends in the upper left corner of the D as if the D is the calorimeters
// depends on the font and size
let beam-endpoint = (0.7cm, +0.35cm)
// minimum prefix width so there is a horizontal line incident
// on the target even if no prefix text is provided
// depends on overall size
let min-prefix-width = 0.25cm
// angle of bend in electron beam so that it looks like its following
let bend-angle = -28deg
// a circular trajectory after the target and into the Dcal
// depends on beam-endpoint and target-shift
// not working, not sure why, leaving hardcoded number rn
//let bend-angle = -1*circular-bend(
// (target-shift.at(0)+beam-endpoint.at(0)).to-absolute().mm(),
// (target-shift.at(1)+beam-endpoint.at(1)).to-absolute().mm()
//)
let the_logo = diagram(
spacing: 0pt, // have node bounding boxes immediately next to each other
node-inset: 0pt, // no inset margin between interior bb and exterior bb
node(
(1,0),
text(size: 32pt, weight: "thin")[L],
shape: rect,
name: <L>,
layer: 1
),
node(
(1.07,0.4),
if type( un ) == content or un == none {
// Assume user knows what they are doing
un
} else {
text(size: 12pt, weight: "light", un )
},
shape: rect,
name: <un>,
layer: 1
),
node(
(0,0),
if prefix == none [] else if type(prefix) == str {
align(top + right, text(size: 15pt, weight: "light", prefix))
} else {
prefix
},
height: text-box-height,
width: if prefix == none { min-prefix-width } else { auto },
name: <prefix>
),
node(
(rel: target-shift, to: <L>),
name: <target>
),
node(
pos: <prefix.west>,
name: <beam-entry>
),
node(
(rel: beam-endpoint, to: <target>),
name: <beam-exit>
),
node(
(2,0),
shape: rect,
text(size: 32pt, fill: dm-text-color, weight: "black")[DM],
name: <DM>,
),
node(
(3,0),
text(size: 32pt, weight: "thin")[X],
name: <X>,
shape: rect,
),
node(
(4,0),
if type(suffix) == content or suffix == none {
// assume user knows what they are doing
suffix
} else {
// assume just a string and we should do our default
align(bottom+left, text(size: 15pt, weight: "light", suffix))
},
name: <suffix>,
shape: rect,
height: text-box-height
),
node(
// intentionally not enclosing <beam-exit> so that the enclosing
// box is vertically symmetric around the letters
enclose: (<beam-entry>, <L>, <DM>, <X>, <suffix>),
fill: bkgd-color,
snap: -1,
name: <LDMX-group>,
inset: 5pt,
),
edge(
<beam-entry>, <target>, electron-ls,
stroke: electron-color + 1pt,
layer: 2
),
edge(
<target>, <beam-exit>, electron-ls,
stroke: electron-color + 1pt,
bend: bend-angle,
layer: 2
),
node(
(rel: (0em, -2pt), to: if suffix == none { <X.north-east> } else { <suffix.north-east> }),
name: <dm-exit-top>
),
node(
(rel: (0em, +2pt), to: if suffix == none { <X.south-east> } else { <suffix.south-east> }),
name: <dm-exit-bottom>
),
edge(
"-",
vertices: (<target>, <dm-exit-bottom>),
stroke: dm-color + 1pt,
layer: 1
),
edge(
"-",
vertices: (<target>, <dm-exit-top>),
stroke: dm-color + 1pt,
layer: 1
),
)
if page-args == auto or page-args == none {
set page(height: auto, width: auto, margin: 0pt, fill: none)
the_logo
} else if page-args == "square" {
let side = measure(the_logo).width
set page(height: side, width: side, margin: 0pt, fill: bkgd-color)
align(center+horizon, the_logo)
} else if type(page-args) == dictionary {
set page(..page-args)
align(center+horizon, the_logo)
} else {
panic(repr(page-args)+" is not auto, "+repr("square")+", or a dictionary")
}
}