Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Last active March 9, 2025 13:09
Show Gist options
  • Save zr-tex8r/86d2f575f919c75a377832d528670a80 to your computer and use it in GitHub Desktop.
Save zr-tex8r/86d2f575f919c75a377832d528670a80 to your computer and use it in GitHub Desktop.
Typst:ゆきだるま☃のマフラーに色を付ける

scmuffler

Typst:ゆきだるま☃のマフラーに色を付ける

パッケージ読込

「原ノ味明朝」フォントがTypstで使用可能である必要がある。

全項目インポートの形式を想定している。

#import "@local/scmuffler:0.3.0": *

使用法

機能一覧

  • scmuffler(«色»)(content): マフラーの部分を指定した色に変えて「原ノ味明朝」の“☃”(U+2603)を出力する。

    引数:

    • «色»(color): マフラーの色。
#import "@local/scmuffler:0.2.0": *
#set page(paper: "a5")
#set text(
lang: "ja", font: "Harano Aji Mincho",
)
私は#scmuffler(olive)よりも#scmuffler(red)の方が好きです。
#let turbo = gradient.linear(..color.map.turbo)
#for k in range(21) {
scmuffler(turbo.sample(k / 20.0 * 100%).darken(25%))
}
#let scmuffler(color) = {
let p = (
((769,371),(-5,-7),(5,8)),
((771,398),(3,-11),(-4,16)),
((751,445),(7,-12),(-3,6)),
((738,451),(5,2),(-21,-8)),
((689,406),(18,13),(-36,-26)),
((522,355),(76,0),(-90,0)),
((311,409),(52,-35),(-20,14)),
((255,453),(25,-4),(-7,1)),
((240,440),(4,8),(-6,-12)),
((222,396),(5,17),(-5,-17)),
((232,365),(-10,9),(6,-6)),
((251,348),(-7,5),(65,-52)),
((527,271),(-112,-3),(25,0)),
((597,280),(-14,-2),(14,2)),
((622,270),(-7,16),(7,-15)),
((643,206),(-5,20),(5,-19)),
((672,189),(-14,-5),(25,10)),
((748,229),(-16,-12),(11,9)),
((757,260),(5,-16),(-7,24)),
((734,318),(5,-14),(-4,10)),
((737,337),(-5,-4),(3,3)),
((752,352),(-6,-7),(6,6)),
).map((c) => {
c.map(((x, y)) => (x*.001em, y*-.001em))
})
let (f, s) = (color, color + .004em)
let v013 = "B" not in str(numbering("\u{3B1}A", 2, 1))
let gr = if v013 { // >= v0.13
let d(ax,ay,_,_,dx,dy,bx,by,ex,ey,..) = {
curve.cubic((ax + dx, ay + dy), (bx + ex, by + ey), (bx, by))
}
let t = p + (p.at(0),)
t = (
curve.move(t.at(0).at(0)),
..range(p.len()).map((i) => {
t.slice(i, i + 2)
}).map(e => d(..e.flatten())),
curve.close(),
)
curve(fill: f, stroke: s, ..t)
} else { // < v0.13
eval("path")(fill: f, stroke: s, closed: true, ..p)
}
box(align(left, {
text(font: "Harano Aji Mincho", "\u{2603}")
h(-1em)
box(width: 1em, gr)
}))
}
[package]
name = "scmuffler"
version = "0.3.0"
entrypoint = "scmuffler.typ"
compiler = "0.6.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment