リファレンス · KanjiVG由来の筆順:描く、描いた漢字から探す
findByDrawing関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The kanji whose strokes are nearest to what was drawn, nearest first. The strokes are compared one by one, in the order they were drawn, so a kanji has to be drawn with the right number of strokes (one more or fewer is allowed, at a cost) and in the order it is written. The size and the place of the drawing do not matter; the lengths and directions of the strokes do. It reads the table as it is and fetches nothing.
インポート
import { findByDrawing } from "@johnmorrisdotca/jisho/strokes";
定義
function findByDrawing(table: PackedStrokes, drawn: readonly (readonly Point[])[], options?: { readonly limit?: number; }): DrawingMatch[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
table | PackedStrokes | What |
drawn | readonly (readonly Point[])[] | The strokes, each a list of points in any units (a canvas's pixels, say), in the order they were drawn. A stroke of one point is a dot. |
options (省略可) | { readonly limit?: number; } |
|
戻り値
DrawingMatch[]
The nearest kanji, with their distances; none for a drawing with no stroke.
例
import { findByDrawing, loadAllStrokes } from "@johnmorrisdotca/jisho/strokes";
const drawn = [[[10, 50], [90, 50]]] as const; // one straight line across
console.log(findByDrawing(await loadAllStrokes(), drawn, { limit: 1 })[0]?.kanji); // 一一出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。