Skip to content

Latest commit

 

History

History
366 lines (220 loc) · 8.08 KB

Kage.md

File metadata and controls

366 lines (220 loc) · 8.08 KB

@kurgm/kage-engine / Kage

Class: Kage

The entry point for KAGE engine (Kanji-glyph Automatic Generating Engine). It generates glyph outlines from a kanji's stroke data described in a dedicated intermediate format called KAGE data.

KAGE data may contain references to other glyphs (components), which are resolved using a storage at its kBuhin property. The data for the referenced glyphs must be registered to the storage prior to generating the outline.

The font (mincho or gothic) can be changed with its kShotai property. The font parameters (stroke width, etc.) can be configured with properties of kFont.

See

Kage.makeGlyph, Kage.makeGlyph2, Kage.makeGlyph3 and Kage.makeGlyphSeparated for usage examples.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Kage(size?)

Parameters

Name Type
size? number

Defined in

kage.ts:86

Properties

kBuhin

kBuhin: Buhin

A storage from which components are looked up.

Defined in

kage.ts:80


kFont

kFont: Font

Provides the way to configure parameters of the currently selected font. Its parameters are reset to the default values when Kage.kShotai is set.

Example

const kage = new Kage();
kage.kFont.kRate = 50;
kage.kFont.kWidth = 3;

Defined in

kage.ts:49


kGothic

Readonly kGothic: kGothic = KShotai.kGothic

An alias of KShotai.kGothic.

See

Kage.kShotai for usage.

Defined in

kage.ts:37


kMincho

Readonly kMincho: kMincho = KShotai.kMincho

An alias of KShotai.kMincho.

See

Kage.kShotai for usage.

Defined in

kage.ts:32


Buhin

Static Readonly Buhin: typeof Buhin = Buhin

An alias of Buhin constructor.

Defined in

kage.ts:24


Polygons

Static Readonly Polygons: typeof Polygons = Polygons

An alias of Polygons constructor.

Defined in

kage.ts:26

Accessors

kShotai

get kShotai(): KShotai

Gets or sets the font as KShotai. Setting this property resets all the font parameters in Kage.kFont. Defaults to KShotai.kMincho.

Returns

KShotai

Example

const kage = new Kage();
kage.kShotai = kage.kGothic;

Defined in

kage.ts:61

set kShotai(shotai): void

Parameters

Name Type
shotai KShotai

Returns

void

Defined in

kage.ts:64


kUseCurve

get kUseCurve(): boolean

Whether to generate contours with off-curve points. An alias of Kage.kFont.kUseCurve.

Returns

boolean

Defined in

kage.ts:72

set kUseCurve(value): void

Parameters

Name Type
value boolean

Returns

void

Defined in

kage.ts:75

Methods

makeGlyph

makeGlyph(polygons, buhin): void

Renders the glyph of the given name. Existing data in polygons (if any) are NOT cleared; new glyph is "overprinted".

Parameters

Name Type Description
polygons Polygons A Polygons instance on which the glyph is rendered.
buhin string The name of the glyph to be rendered.

Returns

void

Example

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

Defined in

kage.ts:106


makeGlyph2

makeGlyph2(polygons, data): void

Renders the glyph of the given KAGE data. Existing data in polygons (if any) are NOT cleared; new glyph is "overprinted".

Parameters

Name Type Description
polygons Polygons A Polygons instance on which the glyph is rendered.
data string The KAGE data to be rendered (in which lines are delimited by "$").

Returns

void

Example

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

Defined in

kage.ts:124


makeGlyph3

makeGlyph3(data): Polygons[]

Renders each stroke of the given KAGE data on separate instances of Polygons.

Parameters

Name Type Description
data string The KAGE data to be rendered (in which lines are delimited by "$").

Returns

Polygons[]

An array of Polygons instances holding the rendered data of each stroke in the glyph.

Example

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

Defined in

kage.ts:148


makeGlyphSeparated

makeGlyphSeparated(data): Polygons[]

Renders each KAGE data fragment in the given array on separate instances of Polygons, with stroke parameters adjusted as if all the fragments joined together compose a single glyph.

Parameters

Name Type Description
data readonly string[] An array of KAGE data fragments (in which lines are delimited by "$") to be rendered.

Returns

Polygons[]

An array of Polygons instances holding the rendered data of each KAGE data fragment.

Example

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

Defined in

kage.ts:182