Skip to the content

Taisen Brackets対戦

Knockout brackets as SVG, from a list of ties.

Taisen (対戦, たいせん) is Japanese for a matchup: two sides facing each other. About the name

Contents

Reference · Where every tie sits

BackgroundImageOptionstype

Your own picture as the background: an image address (http(s), relative or data:image/…; anything else is refused), laid under a veil so the text reads.

Import it

import type { BackgroundImageOptions } from "@johnmorrisdotca/taisen-brackets/layout";

Also exported from: @johnmorrisdotca/taisen-brackets

Definition

interface BackgroundImageOptions {
    image: string;
    fit?: "cover" | "contain";
    dim?: number;
    theme?: "light" | "dark";
}

Members

NameTypeDescription
imagestring
fit (optional)"cover" | "contain" | undefined

cover (the default) fills the drawing; contain shows all of the picture.

dim (optional)number | undefined

How dark (or, in a light look, how pale) the veil is, 0 to 1. Default 0.5.

theme (optional)"light" | "dark" | undefined

Examples

import { drawBracket, type BackgroundImageOptions } from "@johnmorrisdotca/taisen-brackets";

const background: BackgroundImageOptions = { image: "./stadium.webp", fit: "cover", dim: 0.4 };
console.log(drawBracket([{ sides: ["Aurora", "Harbour"], score: [2, 1] }, { sides: ["Cascade", "Delta"], score: [0, 1] }, { sides: ["Aurora", "Delta"], score: [3, 1] }], { background }).startsWith("<svg"));
true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/taisen-brackets 0.20.0.