import { Buhin } from "./buhin.js"; import { Polygons } from "./polygons.js"; import { stretch, Stroke } from "./stroke.js"; import { KShotai, Font } from "./font/index.js"; /** * The entry point for the KAGE engine (Kanji-glyph Automatic Generating Engine). * It generates glyph outlines from kanji stroke data described in a dedicated * intermediate format called {@link https://glyphwiki.org/wiki/GlyphWiki:KAGE%e3%83%87%e3%83%bc%e3%82%bf%e4%bb%95%e6%a7%98 | KAGE data}. * * KAGE data may contain references to other glyphs (components), which are * resolved using a storage in its {@link kBuhin} property. The data for the * referenced glyphs must be registered in the storage prior to generating the outline. * * The font (mincho or gothic) can be changed using the {@link kShotai} property. * Font parameters (stroke width, etc.) can be configured using properties of * {@link kFont}. * * @see {@link Kage.makeGlyph}, {@link Kage.makeGlyph2}, {@link Kage.makeGlyph3} and * {@link Kage.makeGlyphSeparated} for usage examples. */ export declare class Kage { /** An alias for Buhin constructor. */ static readonly Buhin: typeof Buhin; /** An alias for Polygons constructor. */ static readonly Polygons: typeof Polygons; /** * An alias for {@link KShotai.kMincho}. * @see {@link Kage.kShotai} for usage. */ readonly kMincho = KShotai.kMincho; /** * An alias for {@link KShotai.kGothic}. * @see {@link Kage.kShotai} for usage. */ readonly kGothic = KShotai.kGothic; /** * Allows configuration of the parameters for the currently selected font. * Its parameters reset to their default values when {@link Kage.kShotai} is set. * @example * ```ts * const kage = new Kage(); * kage.kFont.kRate = 50; * kage.kFont.kWidth = 3; * ``` */ kFont: Font; /** * Gets or sets the font as {@link KShotai}. Setting this property resets all * font parameters in {@link Kage.kFont}. Defaults to {@link KShotai.kMincho}. * @example * ```ts * const kage = new Kage(); * kage.kShotai = kage.kGothic; * ``` */ get kShotai(): KShotai; set kShotai(shotai: KShotai); /** * Whether to generate contours with off-curve points. * An alias of {@link Kage.kFont}.kUseCurve. */ get kUseCurve(): boolean; set kUseCurve(value: boolean); /** A storage used to look up components. */ kBuhin: Buhin; /** @internal */ readonly stretch: typeof stretch; constructor(size?: number); /** * Renders the glyph of the given name. Existing data in `polygons` (if any) are * NOT cleared; the new glyph is "overprinted". * @example * ```ts * const kage = new Kage(); * kage.kBuhin.push("uXXXX", "1:0:2:32:31:176:31$2:22:7:176:31:170:43:156:63"); * const polygons = new Polygons(); * kage.makeGlyph(polygons, "uXXXX"); * const svg = polygons.generateSVG(); // now `svg` has the string of the rendered glyph * ``` * @param polygons - A {@link Polygons} instance on which the glyph is rendered. * @param buhin - The name of the glyph to be rendered. */ makeGlyph(polygons: Polygons, buhin: string): void; /** * Renders the glyph of the given KAGE data. Existing data in `polygons` (if any) are * NOT cleared; the new glyph is "overprinted". * @example * ```ts * const kage = new Kage(); * const polygons = new Polygons(); * kage.makeGlyph2(polygons, "1:0:2:32:31:176:31$2:22:7:176:31:170:43:156:63"); * const svg = polygons.generateSVG(); // now `svg` has the string of the rendered glyph * ``` * @param polygons - A {@link Polygons} instance on which the glyph is rendered. * @param data - The KAGE data to be rendered (in which lines are delimited by `"$"`). */ makeGlyph2(polygons: Polygons, data: string): void; /** * Renders each stroke of the given KAGE data on separate instances of {@link Polygons}. * @example * ```ts * const kage = new Kage(); * const array = kage.makeGlyph3("1:0:2:32:31:176:31$2:22:7:176:31:170:43:156:63"); * console.log(array.length); // => 2 * console.log(array[0] instanceof Polygons); // => true * ``` * @param data - The KAGE data to be rendered (in which lines are delimited by `"$"`). * @returns An array of {@link Polygons} instances holding the rendered data * of each stroke in the glyph. */ makeGlyph3(data: string): Polygons[]; /** * Renders each KAGE data fragment in the given array on separate instances of * {@link Polygons}, with stroke parameters adjusted as if all fragments together * compose a single glyph. * @example * ```ts * const kage = new Kage(); * const array = kage.makeGlyphSeparated([ * "2:7:8:31:16:32:53:16:65", * "1:2:2:32:31:176:31$2:22:7:176:31:170:43:156:63", * ]); * console.log(array.length); // => 2 * console.log(array[0] instanceof Polygons); // => true * ``` * @param data - An array of KAGE data fragments (in which lines are delimited by `"$"`) * to be rendered. * @returns An array of {@link Polygons} instances holding the rendered data * of each KAGE data fragment. */ makeGlyphSeparated(data: readonly string[]): Polygons[]; protected getEachStrokes(glyphData: string): Stroke[]; protected getEachStrokesOfBuhin(buhin: string, x1: number, y1: number, x2: number, y2: number, sx: number, sy: number, sx2: number, sy2: number): Stroke[]; protected getBox(strokes: Stroke[]): { minX: number; maxX: number; minY: number; maxY: number; }; }