Adds recoloring
Build Successful The Ravenous rulebook was built successfully.
Ravenous/ravenous_typst/pipeline/head This commit looks good
Details
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Free 7.3.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--><path d="M128 320L156.5 92C158.5 76 172.1 64 188.3 64L356.9 64C371.9 64 384 76.1 384 91.1C384 94.3 383.4 97.6 382.3 100.6L336 224L475.3 224C495.5 224 512 240.4 512 260.7C512 268.1 509.8 275.3 505.6 281.4L313.4 562.4C307.5 571 297.8 576.1 287.5 576.1L284.6 576.1C268.9 576.1 256.1 563.3 256.1 547.6C256.1 545.3 256.4 543 257 540.7L304 352L160 352C142.3 352 128 337.7 128 320z"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" fill="black"><!--!Font Awesome Free 7.3.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2026 Fonticons, Inc.--><path d="M128 320L156.5 92C158.5 76 172.1 64 188.3 64L356.9 64C371.9 64 384 76.1 384 91.1C384 94.3 383.4 97.6 382.3 100.6L336 224L475.3 224C495.5 224 512 240.4 512 260.7C512 268.1 509.8 275.3 505.6 281.4L313.4 562.4C307.5 571 297.8 576.1 287.5 576.1L284.6 576.1C268.9 576.1 256.1 563.3 256.1 547.6C256.1 545.3 256.4 543 257 540.7L304 352L160 352C142.3 352 128 337.7 128 320z"/></svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 596 B After Width: | Height: | Size: 610 B |
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
||||
<!-- Tier chevrons -->
|
||||
<path fill="currentColor" d="
|
||||
<path fill="black" d="
|
||||
M128 30
|
||||
L218 112
|
||||
L190 140
|
||||
|
|
@ -17,4 +17,4 @@
|
|||
L38 194
|
||||
Z
|
||||
"></path>
|
||||
</svg>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 325 B |
|
|
@ -1,5 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" role="img" aria-label="Precision icon">
|
||||
<g fill="currentColor">
|
||||
<g fill="black">
|
||||
<!-- Main P body -->
|
||||
<path d="
|
||||
M52 42
|
||||
|
|
@ -36,4 +36,4 @@
|
|||
<line x1="91" y1="118" x2="114" y2="118"></line>
|
||||
<line x1="146" y1="118" x2="169" y2="118"></line>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 928 B After Width: | Height: | Size: 922 B |
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
||||
<!-- Reload loop -->
|
||||
<path fill="currentColor" d="
|
||||
<path fill="black" d="
|
||||
M128 42
|
||||
C174 42 211 75 218 118
|
||||
H184
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
"></path>
|
||||
|
||||
<!-- Small predatory teeth -->
|
||||
<path fill="currentColor" d="
|
||||
<path fill="black" d="
|
||||
M47 103 L28 110 L44 121 Z
|
||||
M38 137 L18 147 L39 155 Z
|
||||
M47 172 L30 188 L54 187 Z
|
||||
|
|
@ -31,4 +31,4 @@
|
|||
|
||||
M157 220 L166 241 L176 213 Z
|
||||
"></path>
|
||||
</svg>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 747 B After Width: | Height: | Size: 734 B |
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
||||
<!-- Crown -->
|
||||
<path fill="currentColor" d="
|
||||
<path fill="black" d="
|
||||
M70 48
|
||||
L70 20
|
||||
L92 37
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
"></path>
|
||||
|
||||
<!-- R -->
|
||||
<path fill="currentColor" d="
|
||||
<path fill="black" d="
|
||||
M58 76
|
||||
H132
|
||||
C176 76 200 98 200 133
|
||||
|
|
@ -32,4 +32,4 @@
|
|||
C164 115 151 106 128 106
|
||||
Z
|
||||
"></path>
|
||||
</svg>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 566 B After Width: | Height: | Size: 553 B |
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
||||
<!-- Open book -->
|
||||
<path fill="currentColor" d="
|
||||
<path fill="black" d="
|
||||
M24 52
|
||||
C61 47 96 55 128 78
|
||||
C160 55 195 47 232 52
|
||||
|
|
@ -33,5 +33,5 @@
|
|||
M151 116 Q172 103 201 103
|
||||
M151 141 Q172 128 201 128
|
||||
M151 166 Q172 153 201 153
|
||||
" fill="none" stroke="currentColor" stroke-width="7" stroke-linecap="round"></path>
|
||||
</svg>
|
||||
" fill="none" stroke="black" stroke-width="7" stroke-linecap="round"></path>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 816 B After Width: | Height: | Size: 803 B |
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
||||
<!-- Simplified hourglass / cost -->
|
||||
<path fill="currentColor" d="
|
||||
<path fill="black" d="
|
||||
M58 28
|
||||
H198
|
||||
V52
|
||||
|
|
@ -28,4 +28,4 @@
|
|||
H160
|
||||
Z
|
||||
"></path>
|
||||
</svg>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 522 B After Width: | Height: | Size: 516 B |
|
|
@ -120,11 +120,153 @@
|
|||
inset: 0pt,
|
||||
image("/images/icons/skull-fill.svg"),
|
||||
)
|
||||
#let wine-box(..args) = box(
|
||||
#let wine-box = box(
|
||||
height: 0.65em,
|
||||
baseline: 0.5pt,
|
||||
inset: 0pt,
|
||||
image("/images/icons/wine-fill.svg"),
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// SVG RECOLORING
|
||||
// =============================================================================
|
||||
|
||||
#let re-colorize(svg-box, color) = {
|
||||
let outer = svg-box
|
||||
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: expected an image or boxed image, "
|
||||
+ "but no image source was found.",
|
||||
)
|
||||
}
|
||||
|
||||
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, got `" + source-path + "`.",
|
||||
)
|
||||
}
|
||||
|
||||
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-path
|
||||
+ "` does not appear to contain SVG markup.",
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Recolor black.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
let replacement = color.to-hex()
|
||||
let black-pattern = regex(
|
||||
"(?i)(#000000\\b|#000\\b|\\bblack\\b|rgb\\(\\s*0\\s*[, ]\\s*0\\s*[, ]\\s*0\\s*\\))",
|
||||
)
|
||||
|
||||
let recolored = svg.replace(black-pattern, replacement)
|
||||
|
||||
if recolored == svg {
|
||||
panic(
|
||||
"re-colorize: no black color could be replaced in `" + source-path + "`.",
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 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")
|
||||
|
||||
// If the image is wrapped in a box with explicit dimensions,
|
||||
// prefer those dimensions.
|
||||
let outer-width = outer.at("width", default: auto)
|
||||
let outer-height = outer.at("height", default: auto)
|
||||
|
||||
let width = if outer-width != auto {
|
||||
outer-width
|
||||
} else {
|
||||
image-width
|
||||
}
|
||||
|
||||
let height = if outer-height != auto {
|
||||
outer-height
|
||||
} else {
|
||||
image-height
|
||||
}
|
||||
|
||||
// show image: it => image(
|
||||
// bytes(recolored),
|
||||
// width: width,
|
||||
// height: height,
|
||||
// fit: image-fit,
|
||||
// )
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,26 @@
|
|||
#import "/setup/setup.typ": macros, symbols
|
||||
|
||||
#show box: it => symbols.try-re-colorize(it, blue)
|
||||
|
||||
This is a test of symbols, in various environments: @blood:short, @jauge:short, @ar_end, @ar_tier, @ar_lvl, @ar_time, @ar_tox, @ar_wine, @ar_cst, @rl_integrite, @rl_protection, @rl_reload, @rl_rmax, @rl_am, @rl_arbreak, @rl_parmure, @rl_precision, @ca_torque
|
||||
|
||||
|
||||
#symbols.cost-box
|
||||
#symbols.try-re-colorize(symbols.blood-box, green)
|
||||
|
||||
|
||||
= Old
|
||||
// #let c1 = read("c1.svg");
|
||||
// #let c2 = read("c2.svg");
|
||||
// #let c1 = c1.replace("#000000", green.hex())
|
||||
// #let c2 = c2.replace("#000000", green.hex())
|
||||
// #image.decode(c1, width: 25pt)
|
||||
// #image.decode(c2, width: 25pt)
|
||||
|
||||
// = New
|
||||
// #let c1 = read("c1.svg");
|
||||
// #let c2 = read("c2.svg");
|
||||
// #let c1 = colorize(c1, green);
|
||||
// #let c2 = colorize(c2, green);
|
||||
// #image.decode(c1, width: 25pt)
|
||||
// #image.decode(c2, width: 25pt)
|
||||
|
|
|
|||