-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathsublattice-points.typ
76 lines (68 loc) · 1.79 KB
/
sublattice-points.typ
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
#import "@preview/cetz:0.3.4": canvas, draw
#import draw: line, content, circle, on-layer
#set page(width: auto, height: auto, margin: 8pt)
// Atom with 3D shading effect
#let shaded-circle(pos, color, radius: 0.1, name: none, stroke: 0.2pt) = {
circle(
pos,
radius: radius,
stroke: stroke,
fill: gradient.radial(
color.lighten(85%),
color,
color.darken(25%),
focal-center: (25%, 20%),
focal-radius: 10%,
center: (30%, 25%),
),
name: name,
)
}
#canvas({
// Define styles and constants
let grid-size = 2 // number of points in each direction
let spacing = 0.6 // spacing between points
let dot-radius = 0.1
// Colors in order of appearance
let colors = (
rgb("#4040d9"), // blue
rgb("#90EE90"), // light green
rgb("#006400"), // dark green
rgb("#9ACD32"), // yellow green
rgb("#FFA500"), // orange
rgb("#FF0000"), // red
rgb("#000000"), // black
rgb("#800080"), // purple
)
for ii in range(0, 5) {
for jj in range(0, 8) {
let x = 2 * ii * spacing
let y = 2 * jj * spacing
// Every 2 right and 1 up is same color
// Use modulo to cycle through colors
let color-idx = calc.rem(ii - 2 * jj, colors.len())
if color-idx < 0 { color-idx += colors.len() }
// Use the shaded-circle function instead of regular circle
shaded-circle(
(x, y),
colors.at(color-idx),
radius: dot-radius * 1.2,
name: str(ii) + "," + str(jj),
)
}
}
// Add arrows to show basis vectors
let arrow-style = (
mark: (end: "stealth", fill: black, scale: .5),
stroke: 1pt,
)
on-layer(
-1,
{
line("0,0", "2,1", ..arrow-style)
line("0,0", "0,4", ..arrow-style)
line("2,1", "2,5")
line("0,4", "2,5")
},
)
})