@kurgm/kage-engine / Kage
Defined in: kage.ts:22
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 KAGE data.
KAGE data may contain references to other glyphs (components), which are resolved using a storage in its 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 kShotai property. Font parameters (stroke width, etc.) can be configured using properties of kFont.
Kage.makeGlyph, Kage.makeGlyph2, Kage.makeGlyph3 and Kage.makeGlyphSeparated for usage examples.
new Kage(
size?):Kage
Defined in: kage.ts:86
number
Kage
kBuhin:
Buhin
Defined in: kage.ts:80
A storage used to look up components.
kFont:
Font
Defined in: kage.ts:49
Allows configuration of the parameters for the currently selected font. Its parameters reset to their default values when Kage.kShotai is set.
const kage = new Kage();
kage.kFont.kRate = 50;
kage.kFont.kWidth = 3;
readonlykGothic:kGothic=KShotai.kGothic
Defined in: kage.ts:37
An alias for KShotai.kGothic.
Kage.kShotai for usage.
readonlykMincho:kMincho=KShotai.kMincho
Defined in: kage.ts:32
An alias for KShotai.kMincho.
Kage.kShotai for usage.
readonlystaticBuhin: typeofBuhin
Defined in: kage.ts:24
An alias for Buhin constructor.
readonlystaticPolygons: typeofPolygons
Defined in: kage.ts:26
An alias for Polygons constructor.
get kShotai():
KShotai
Defined in: kage.ts:61
Gets or sets the font as KShotai. Setting this property resets all font parameters in Kage.kFont. Defaults to KShotai.kMincho.
const kage = new Kage();
kage.kShotai = kage.kGothic;set kShotai(
shotai):void
Defined in: kage.ts:64
void
get kUseCurve():
boolean
Defined in: kage.ts:72
Whether to generate contours with off-curve points. An alias of Kage.kFont.kUseCurve.
boolean
set kUseCurve(
value):void
Defined in: kage.ts:75
boolean
void
makeGlyph(
polygons,buhin):void
Defined in: kage.ts:106
Renders the glyph of the given name. Existing data in polygons (if any) are
NOT cleared; the new glyph is "overprinted".
A Polygons instance on which the glyph is rendered.
string
The name of the glyph to be rendered.
void
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 glyphmakeGlyph2(
polygons,data):void
Defined in: kage.ts:124
Renders the glyph of the given KAGE data. Existing data in polygons (if any) are
NOT cleared; the new glyph is "overprinted".
A Polygons instance on which the glyph is rendered.
string
The KAGE data to be rendered (in which lines are delimited by "$").
void
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 glyphmakeGlyph3(
data):Polygons[]
Defined in: kage.ts:147
Renders each stroke of the given KAGE data on separate instances of Polygons.
string
The KAGE data to be rendered (in which lines are delimited by "$").
Polygons[]
An array of Polygons instances holding the rendered data of each stroke in the glyph.
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); // => truemakeGlyphSeparated(
data):Polygons[]
Defined in: kage.ts:181
Renders each KAGE data fragment in the given array on separate instances of Polygons, with stroke parameters adjusted as if all fragments together compose a single glyph.
readonly string[]
An array of KAGE data fragments (in which lines are delimited by "$")
to be rendered.
Polygons[]
An array of Polygons instances holding the rendered data of each KAGE data fragment.
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