本文へ移動

Koyomi Calendars暦

カレンダーのページをSVGで描きます。1日を18種類のアイコンで、1か月をポスターや卓上カレンダーで、そして日めくりも使えます。

「暦」(こよみ) は、カレンダーのことです。 名前について(英語)

目次

リファレンス · /themes/heavy

theme定数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

The heavy design's drawing, for the package's own renderer: heavy black outline, ring slots over the top edge, black header rule.

Most code wants calendarIcon from this file instead, which draws with it.

インポート

import { theme } from "@johnmorrisdotca/koyomi-calendars/themes/heavy";

定義

const theme: Def = {
    box: [38, 60, 352, 320],
    numeral: "centre",
    layout: () => ({ page: HEAVY, yearZone: HEAVY }),
    draw: ({ p, dark, l }) => {
        const k = dark ? { line: "#f2f2f2", body: "#161616", ink: "#f2f2f2" } : { line: "#000000", body: "#ffffff", ink: "#000000" };
        const ring = (cx: number) => rect(cx - 23.5, 69, 47, 63, 23.5, k.line) + rect(cx - 10.5, 82, 21, 40, 10.5, k.body);
        const [x, y, w, h] = l.page;
        const ms = fit(p.monthUp, 44, 220, 0.84);
        const [mb, db, yb] = stack(y, y + h, [[ms * CAP, 0], [90 * CAP, 12], ...(p.year ? [[25 * CAP, 12] as const] : [])]);
        return (rect(55.5, 104.5, 317, 257, 14, k.body, `stroke="${k.line}" stroke-width="21"`) +
            `<path d="M46 174h336" stroke="${k.line}" stroke-width="19"/>` +
            ring(106.75) + ring(178.25) + ring(249.75) + ring(321.25) +
            part("month", tx(x + w / 2, mb!, p.monthUp, ms, k.ink, 900, { family: BLACK })) +
            part("day", dayText(x + w / 2, db!, p.day, 90, k.ink, 900, { family: BLACK })) +
            part("year", tx(x + w / 2, yb!, p.year, 25, k.ink, 900, { family: BLACK, opacity: 0.55 })));
    },
}

メンバー

名前型説明
boxRect

The drawing's own coordinate box: x, y, width, height.

numeral"centre"

Where the day sits in its page. Every theme centres it; a look that places it otherwise says so here, for 1, 9, 30 and 31 alike.

layout(year: boolean, weekend?: boolean) => CalendarLayout

The layout with a year and without one (the drawing is re-centred when the year is absent), and, for a theme with a weekend page, as that page.

draw(c: Ctx) => string
rings (省略可)readonly [x: number, y: number, width: number] | undefined

Where rings stand: x, y and width of the page's top edge, in the drawing's units. A theme without it ignores rings.

weekend (省略可)true | undefined

The theme has a weekend page (weekend: "split").

extras (省略可)((input: ExtrasInput) => Extras) | undefined

Works out the extra data a tear-off page draws. A theme without it is given none.

例

import { theme } from "@johnmorrisdotca/koyomi-calendars/themes/heavy";

console.log(theme.box.length);
4

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/koyomi-calendars 0.3.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。