273 lines
5.6 KiB
Plaintext
273 lines
5.6 KiB
Plaintext
#import "variables.typ": theme, theme-var
|
|
#import "../core/limits.typ": hunbal
|
|
|
|
#let star-base-sym = theme-var("star")
|
|
#let star-box = text(fill: black, top-edge: 0.5em, size: 1.3em)[#star-base-sym]
|
|
#let empty-star-box = text(
|
|
fill: white,
|
|
size: 1.3em,
|
|
top-edge: 0.5em,
|
|
stroke: 0.6pt + black,
|
|
)[#star-base-sym]
|
|
|
|
#let dmg-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/sword.svg"),
|
|
)
|
|
#let blood-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/blood.svg"),
|
|
)
|
|
#let jauge-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/bolt-lightning-solid-full.svg"),
|
|
)
|
|
|
|
#let torque-box = box(
|
|
height: 0.75em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/torque_color.svg"),
|
|
)
|
|
|
|
#let precision-box = text(fill: green, box(
|
|
height: 0.85em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/precision.svg"),
|
|
))
|
|
|
|
#let parmure-box = text(fill: green, box(
|
|
height: 0.85em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/armor_pierce.svg"),
|
|
))
|
|
#let arbreak-box = text(fill: green, box(
|
|
height: 0.75em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/arbreakk_color.svg"),
|
|
))
|
|
|
|
#let am-box = box(
|
|
height: 0.75em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/antimaterial.svg"),
|
|
)
|
|
|
|
#let rmax-box = box(
|
|
height: 0.85em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/rmax.svg"),
|
|
)
|
|
|
|
#let reload-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/reload.svg"),
|
|
)
|
|
#let protection-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/protection.svg"),
|
|
)
|
|
#let integrity-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/integrity.svg"),
|
|
)
|
|
#let cost-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/coins.svg"),
|
|
)
|
|
#let end-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/flag-banner.svg"),
|
|
)
|
|
#let tier-box = box(
|
|
height: 0.75em,
|
|
baseline: 0.2pt,
|
|
inset: 0pt,
|
|
image("/images/icons/tier.svg"),
|
|
)
|
|
|
|
#let lvl-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/level.svg"),
|
|
)
|
|
|
|
#let time-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/time.svg"),
|
|
)
|
|
#let tox-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/skull-fill.svg"),
|
|
)
|
|
#let wine-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/icons/wine-fill.svg"),
|
|
)
|
|
#let sen-holy-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/yonsen_glyphs/hunter_v3.svg"),
|
|
)
|
|
#let sen-hunter-box = box(
|
|
height: 0.65em,
|
|
baseline: 0.5pt,
|
|
inset: 0pt,
|
|
image("/images/yonsen_glyphs/saint.svg"),
|
|
)
|
|
|
|
//----- SVG RECOLORING -----
|
|
|
|
#let re-colorize(svg-box, color) = {
|
|
let current = svg-box
|
|
let source = none
|
|
let image-node = none
|
|
|
|
//----- Unwrap boxes until we find an image source. -----
|
|
|
|
for _ in range(2) {
|
|
let direct-source = current.at("source", default: none)
|
|
|
|
if direct-source != none {
|
|
source = direct-source
|
|
image-node = current
|
|
break
|
|
}
|
|
|
|
let body = current.at("body", default: none)
|
|
|
|
if body == none {
|
|
break
|
|
}
|
|
|
|
current = body
|
|
}
|
|
|
|
if source == none {
|
|
// panic("re-colorize: no image source was found.")
|
|
return svg-box
|
|
}
|
|
|
|
let source-path = str(source)
|
|
|
|
// Case-insensitive `.svg` extension check.
|
|
if source-path.find(regex("(?i)\\.svg$")) == none {
|
|
// panic("re-colorize: expected an SVG image.")
|
|
return svg-box
|
|
}
|
|
|
|
let svg = read(source-path)
|
|
|
|
// Also verify that the contents actually look like SVG.
|
|
if svg.find(regex("(?i)<svg(?:\\s|>)")) == none {
|
|
// panic("re-colorize: source does not contain SVG markup.")
|
|
return svg-box
|
|
}
|
|
|
|
//----- Recolor fills. -----
|
|
|
|
let replacement = color.to-hex()
|
|
let fill-pattern = regex("(?i)fill\\s*=\\s*\"[^\"]*\"")
|
|
let recolored = svg.replace(fill-pattern, "fill=\"" + replacement + "\"")
|
|
|
|
if recolored == svg {
|
|
// panic("re-colorize: no fill attribute could be replaced.")
|
|
return svg-box
|
|
}
|
|
|
|
//----- Preserve sizing. -----
|
|
|
|
let image-width = image-node.at("width", default: auto)
|
|
let image-height = image-node.at("height", default: auto)
|
|
let image-fit = image-node.at("fit", default: "cover")
|
|
|
|
let recolored-image = image(
|
|
bytes(recolored),
|
|
width: image-width,
|
|
height: image-height,
|
|
fit: image-fit,
|
|
)
|
|
|
|
// Rebuild the wrapper chain while replacing only the image itself. This
|
|
// keeps box properties such as height, baseline, inset, stroke, and fill.
|
|
let replace-image(node) = {
|
|
if node.at("source", default: none) != none {
|
|
recolored-image
|
|
} else {
|
|
let body = node.at("body", default: none)
|
|
if body == none {
|
|
// panic("re-colorize: could not rebuild the image wrapper.")
|
|
return node
|
|
}
|
|
|
|
let fields = node.fields()
|
|
let _ = fields.remove("body")
|
|
node.func()(replace-image(body), ..fields)
|
|
}
|
|
}
|
|
|
|
replace-image(svg-box)
|
|
}
|
|
|
|
// Safe version:
|
|
// suitable for show rules and generic content.
|
|
#let try-re-colorize(body, color) = {
|
|
let current = body
|
|
let source = none
|
|
for _ in range(8) {
|
|
let direct-source = current.at("source", default: none)
|
|
if direct-source != none {
|
|
source = direct-source
|
|
break
|
|
}
|
|
let inner = current.at("body", default: none)
|
|
if inner == none {
|
|
break
|
|
}
|
|
current = inner
|
|
}
|
|
|
|
// Not an image-like thing.
|
|
if source == none {
|
|
return body
|
|
}
|
|
|
|
let source-path = str(source)
|
|
|
|
// Image, but not SVG.
|
|
if source-path.find(regex("(?i)\\.svg$")) == none {
|
|
return body
|
|
}
|
|
|
|
re-colorize(body, color)
|
|
}
|