0.2.0 • Published 5 years ago

react-zh-stroker v0.2.0

Weekly downloads
-
License
CC0-1.0
Repository
-
Last release
5 years ago

react-zh-stroker

A stroke drawing React component for zh-stroke-data.

Quick Start

Install with following commands.

npm install react-zh-stroker
# or
yarn add react-zh-stroker

react-zh-stroker is designed to draw JSON stroke data from 常用國字標準字體筆順學習網, which are processed and stored in zh-stroke-data.

For example, if you want to draw 萌 (json/840c.json) in your app:

import { data, Word } from 'react-zh-stroker';
import word from './json/840c.json';

const moe = data.computeLength(word);

function App() {
  return (
    <Word data={moe} progress={1.0} />
  );
}

By changing the progress property dynamically, you can animate the word.

APIs

Word component

Word draws a JSON stroke data.

onEnter event

onEnter is triggered when a word is starting to draw.

onLeave event

onLeave is triggered when a word is finishing to draw.

onEnterStroke event

onEnterStroke is triggered when a stroke in a word is starting to draw.

onLeaveStroke event

onLeaveStroke is triggered when a stroke in a word is finishing to draw.

Stroke component

Stroke draws a stroke in a JSON stroke data.

Track component

Track draws a path.

data.fromXML

data.fromXML is a helper to read a stroke data in XML format.

data.packedFromPath

data.packedFromPath is a helper to compute the index of a word in a packed binary stroke data.

data.fromBinary

data.fromBinary is a helper to read a stroke data in binary format.

data.fromScanline

data.fromScanline is a helper to read a stroke data in scanline format.

data.computeLength

data.computeLength is a helper to compute the length of a word.

Development

yarn install
yarn start

License

0.2.0

5 years ago

0.1.14

5 years ago

0.1.15

5 years ago

0.1.13

5 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago