Skip to the content

Chizu地図

Draw SVG maps, frame regions, place numbered callouts and build geography quizzes with English and Japanese names.

Chizu is the Japanese word 地図 for map. About the name

Contents

Reference · Framing, geometry and quiz tools

DistractorOptionstype

The wrong-answer count, optional seeded random source and candidate restriction.

Import it

import type { DistractorOptions } from "@johnmorrisdotca/chizu";

Definition

type DistractorOptions = {
    count?: number;
    pool?: number;
    random?: Random;
    among?: ReadonlyArray<string | number>;
};

Members

NameTypeDescription
count (optional)number | undefined

How many wrong answers. Default 3.

pool (optional)number | undefined

How many of the most tempting places the wrong answers are drawn from. Default count + 3: wider than count, so that the same three look-alikes are not offered every time the question comes round.

random (optional)Random | undefined

The stream the draw is made from: the same seed offers the same choices. Default: the best count, with no draw.

among (optional)readonly (string | number)[] | undefined

Codes that may be offered, if only some may be (the countries a school names). The target's own code is never offered. Default: every region.

Examples

import WORLD from "@johnmorrisdotca/chizu/world";
import { pickDistractors, seededRandom, type DistractorOptions } from "@johnmorrisdotca/chizu";

const options: DistractorOptions = { count: 5, random: seededRandom(1) };
console.log(pickDistractors(WORLD, "BR", options).length);
// 5
5

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/chizu 1.5.0.