Cartoon of the AlCoCrFeNi high entropy alloy (HEA) with body-centered cubic (BCC) lattice. HEAs also come in face-centered cubic (FCC) and (less frequently) hexagonal close packing (HCP). BCC HEAs typically have high yield strength and low ductility, vice versa for FCC HEAs. Wiki article.
#import "@preview/cetz:0.5.2": canvas, draw
#import draw: circle, content
// The flat disc underneath is fully covered by the gradient, but drawing both
// doubles up the antialiased rim so the sphere keeps a crisp edge.
#let sphere(pos, radius: 0.25, fill: luma(50), ..args) = {
circle(pos, radius: radius, stroke: none, fill: fill, ..args)
circle(pos, radius: radius, stroke: none, fill: gradient.radial(
fill.lighten(75%),
fill,
fill.darken(15%),
// Offset the highlight to suggest a lit sphere.
focal-center: (30%, 25%),
focal-radius: 5%,
center: (35%, 30%),
))
}
#set page(width: auto, height: auto, margin: 5pt, fill: none)
#set text(size: 12pt)
#let atom(pos, color, radius: 0.3, element: none, name: none) = {
sphere(pos, radius: radius, fill: color)
if element != none {
content(
pos,
text(fill: white, weight: "bold", size: 12pt)[#element],
anchor: "center",
name: name,
)
}
}
#canvas({
// Define colors for the high-entropy alloy (equivalent to the LaTeX colors but toned down)
let colors = (
rgb("#cc3333"),
rgb("#006666"),
rgb("#3333cc"),
rgb("#cc8000"),
rgb("#aaaaee"),
)
// Function to get a "random" color from the colors array
// Since Typst doesn't have a random function, we'll use a deterministic pattern
// based on position to create a random-looking distribution
let pseudo-random-color(i, j, k) = {
let index = calc.rem(i * 3 + j * 5 + k * 7, colors.len())
colors.at(index)
}
// viewing angle parameters
let x-factor = 0.3
let y-factor = -0.18
let z-spacing = 1.1
// This is equivalent to the nested foreach loops in the LaTeX code
for i in range(12) {
for j in range(4) {
// First set of atoms (equivalent to the first nested loop in LaTeX)
for k in range(4) {
atom(
(-i + x-factor * j, y-factor * j + z-spacing * k),
pseudo-random-color(i, j, k),
)
}
// Second set of atoms (equivalent to the second nested loop in LaTeX)
for k in range(3) {
atom(
(-i + 0.5 + x-factor * j, y-factor * j + z-spacing * k + 0.65),
pseudo-random-color(i, j, k + 10),
)
}
}
}
// Draw the legend (moved further down)
let elements = (
("Al", rgb("#cc3333")), // red!80 (toned down)
("Co", rgb("#3333cc")), // blue!80 (toned down)
("Cr", rgb("#006666")), // teal (toned down)
("Fe", rgb("#cc8000")), // orange (toned down)
("Ni", rgb("#aaaaee")), // blue!20 (toned down)
)
// Position the legend further down
let legend-y-start = 3
let legend-spacing = 0.8
for (idx, (element, color)) in elements.enumerate() {
atom(
(2.5, legend-y-start - idx * legend-spacing),
color,
element: element,
)
}
})