### React Quick Start Example
Source: https://github.com/kurtgokhan/tegaki/blob/main/README.md
A basic React component demonstrating how to use TegakiRenderer with a built-in font. Ensure the 'tegaki' package is installed.
```tsx
import { TegakiRenderer } from 'tegaki';
import caveat from 'tegaki/fonts/caveat';
function App() {
return (
Hello World
);
}
```
--------------------------------
### Run Example App
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/nuxt.mdx
Instructions to clone and run the example Nuxt application from the Tegaki repository.
```sh
bun install
bun --filter @tegaki/example-nuxt dev
```
--------------------------------
### Use Tegaki from CDN via esm.sh
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/web-components.mdx
Integrate Tegaki using a CDN for quick setup without build tools. This example uses esm.sh to serve the modules.
```html
```
--------------------------------
### Clone Repository and Install Dependencies
Source: https://github.com/kurtgokhan/tegaki/blob/main/CONTRIBUTING.md
Clone the Tegaki repository and install its dependencies using Bun. This sets up the project environment for development.
```bash
git clone https://github.com/KurtGokhan/tegaki.git
cd tegaki
bun install
```
--------------------------------
### Install Tegaki via npm
Source: https://github.com/kurtgokhan/tegaki/blob/main/README.md
Install the Tegaki package using npm. This is the first step to using Tegaki in your project.
```bash
npm install tegaki
```
--------------------------------
### Install HyperFrames Skills
Source: https://github.com/kurtgokhan/tegaki/blob/main/examples/hyperframes/AGENTS.md
Install the necessary AI agent skills for the HyperFrames framework. This command adds framework-specific patterns for composition.
```bash
npx skills add heygen-com/hyperframes
```
--------------------------------
### Full Standalone Tegaki CDN Example
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/web-components.mdx
A complete HTML file demonstrating Tegaki usage via CDN, suitable for direct use in a browser. It includes the necessary imports and element registration.
```html
Tegaki CDN Example
```
--------------------------------
### Initialize TegakiEngine in Vanilla JS
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/vanilla.mdx
Basic setup for TegakiEngine with a container, text, font, and uncontrolled time settings. The engine automatically creates DOM elements.
```html
```
--------------------------------
### Basic SolidJS Tegaki Renderer
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/solid.mdx
A simple example demonstrating how to render text with a specified font and uncontrolled animation settings. Ensure 'tegaki/solid' and the font bundle are imported.
```tsx
import { TegakiRenderer } from 'tegaki/solid';
import bundle from 'tegaki/fonts/caveat';
function App() {
return (
);
}
```
--------------------------------
### Basic TegakiRenderer Example
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/nuxt.mdx
Demonstrates a simple integration of TegakiRenderer in a Nuxt page, rendering static text with a specified font and uncontrolled animation.
```vue
```
--------------------------------
### Development Commands for Tegaki
Source: https://github.com/kurtgokhan/tegaki/blob/main/CONTRIBUTING.md
Execute common development tasks for Tegaki projects using Bun workspace scripts. These commands cover starting the generator, running the dev server, testing, type checking, and linting.
```bash
bun start # Run the generator CLI
bun dev # Start the website dev server (http://localhost:4321/tegaki/)
bun run test # Run tests across all packages
bun typecheck # TypeScript checks
bun check # Biome lint + format check
bun fix # Biome auto-fix (safe + unsafe)
bun checks # Everything: lint + format + typecheck + tests
```
--------------------------------
### Basic React Tegaki Renderer
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/react.mdx
Demonstrates the fundamental usage of TegakiRenderer in a React component. Ensure 'tegaki' and 'react-dom' are installed.
```tsx
import { TegakiRenderer } from 'tegaki';
import bundle from 'tegaki/fonts/caveat';
function App() {
return (
Hello World
);
}
```
--------------------------------
### Streaming Text with Tegaki in SolidJS
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/solid.mdx
Example of rendering text that animates in a streaming fashion, suitable for dynamic messages. Uses 'uncontrolled' time mode with a higher speed and a 'catchUp' value. Requires 'tegaki/solid' and a font bundle.
```tsx
import { TegakiRenderer } from 'tegaki/solid';
import bundle from 'tegaki/fonts/caveat';
function StreamingMessage(props: { text: string }) {
return (
);
}
```
--------------------------------
### Framework-Specific Imports
Source: https://github.com/kurtgokhan/tegaki/blob/main/README.md
Import TegakiRenderer based on your framework. This example shows imports for React, Svelte, Vue, and SolidJS.
```tsx
import { TegakiRenderer } from 'tegaki/react'; // React
import { TegakiRenderer } from 'tegaki/svelte'; // Svelte
import { TegakiRenderer } from 'tegaki/vue'; // Vue
import { TegakiRenderer } from 'tegaki/solid'; // SolidJS
```
--------------------------------
### Controlled Time Example
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/nuxt.mdx
Shows how to control the animation progress of TegakiRenderer using a range input slider, allowing scrubbing through the text animation.
```vue
```
--------------------------------
### Start Drawing After Delay
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/remotion.mdx
Calculates progress to introduce a delay before starting the drawing animation, allowing for a pause before the text appears.
```tsx
const {fps} = useVideoConfig();
const delayFrames = fps; // 1s delay
const drawFrames = 120; // 2s to draw
const progress = Math.max(0, Math.min(1, (frame - delayFrames) / drawFrames));
```
--------------------------------
### Tegaki Font Bundle Imports
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/guides/bundlers.mdx
Example of how Tegaki's font bundles use ESM import-attributes syntax to load assets like font URLs and glyph data.
```typescript
// inside tegaki/fonts//bundle.ts (and any bundle the generator produces)
import fontUrl from './.ttf' with { type: 'url' };
import glyphData from './glyphData.json' with { type: 'json' };
```
--------------------------------
### Update Linux Baseline for Text Preview E2E Tests (Docker)
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
Updates the Linux baseline snapshots for the text preview end-to-end tests using a Dockerized Playwright environment. This command requires Docker to be installed and is necessary for CI compatibility. Navigate to the 'packages/website' directory before running.
```bash
cd packages/website && bun test:e2e:docker:update
```
--------------------------------
### Controlled Time Animation with TegakiEngine
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/vanilla.mdx
Example of using controlled time for animation by manually updating the time property on each frame using `requestAnimationFrame`.
```js
const engine = new TegakiEngine(container, {
text: 'Controlled',
font: bundle,
time: 0,
});
let t = 0;
function animate() {
t += 0.016;
engine.update({ time: t });
requestAnimationFrame(animate);
}
animate();
```
--------------------------------
### Basic TegakiRenderer Usage in Vue
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/vue.mdx
Demonstrates the fundamental setup for using the TegakiRenderer component in a Vue 3 application. Imports the necessary renderer and font bundle, then renders static text with basic time and style configurations.
```vue
```
--------------------------------
### Accessing Tegaki Renderer Handle in SolidJS
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/solid.mdx
Shows how to get a reference to the TegakiRenderer's handle using a callback ref. This handle provides access to the underlying TegakiEngine instance and the container element. Requires 'TegakiRendererHandle' type.
```tsx
import { TegakiRenderer, type TegakiRendererHandle } from 'tegaki/solid';
import bundle from 'tegaki/fonts/caveat';
function App() {
let handle: TegakiRendererHandle;
return (
(handle = h)}
font={bundle}
text="Hello World"
time={{ mode: 'uncontrolled', speed: 1 }}
style={{ 'font-size': '48px' }}
/>
);
}
```
--------------------------------
### Drive Animation with CSS Time Mode
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/web-components.mdx
Set the 'time' attribute to 'css' to enable CSS time mode, allowing the animation to be driven by CSS custom properties. Refer to the rendering guide for detailed setup.
```html
```
--------------------------------
### Registering and Using a Font Bundle in Astro
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/astro.mdx
Demonstrates how to register a font bundle once and then use it by name across multiple components to avoid data duplication. Includes an option to preload the font.
```astro
---
import TegakiRenderer from 'tegaki/astro';
import bundle from 'tegaki/fonts/caveat';
---
```
```astro
```
--------------------------------
### Basic Astro Component Usage
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/astro.mdx
Renders 'Hello World' with the Caveat font using the Tegaki Astro component. Suitable for simple text animations.
```astro
---
import TegakiRenderer from 'tegaki/astro';
import bundle from 'tegaki/fonts/caveat';
---
```
--------------------------------
### React TegakiRenderer Usage
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/guides/rendering.mdx
Integrate TegakiRenderer in a React application to display handwriting animations. Ensure the 'tegaki' package is installed.
```tsx
import { TegakiRenderer } from 'tegaki';
import bundle from 'tegaki/fonts/caveat';
Hello World
```
--------------------------------
### Run Darwin Text Preview E2E Tests
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
Executes the text preview end-to-end tests on the local Darwin environment. Ensure you are in the 'packages/website' directory.
```bash
bun test:e2e
```
--------------------------------
### Register Font Bundle Globally
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/vanilla.mdx
Shows how to register a font bundle globally using `TegakiEngine.registerBundle()` for easy referencing by name in subsequent initializations.
```js
import { TegakiEngine } from 'tegaki/core';
import caveat from 'tegaki/fonts/caveat';
TegakiEngine.registerBundle(caveat);
// Later, anywhere in your app:
const engine = new TegakiEngine(container, {
text: 'Hello',
font: 'Caveat', // resolved from the registry
});
```
--------------------------------
### Pre-render Elements with TegakiEngine for SSR
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/vanilla.mdx
Illustrates server-side rendering using `TegakiEngine.renderElements()` to generate HTML on the server and adopt it on the client for initial rendering.
```js
import { TegakiEngine } from 'tegaki/core';
// Server: render to HTML string
const html = TegakiEngine.renderElements(
{ text: 'Hello', font: bundle },
(tag, props, ...children) => {
// your HTML string builder
},
);
// Client: adopt pre-rendered DOM
const engine = new TegakiEngine(container, { adopt: true, text: 'Hello', font: bundle });
```
--------------------------------
### Tegaki Agent Processing Pipeline
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
The sequence of operations performed by the Tegaki agent for each glyph, starting from font download and ending with JSON output.
```text
Font download -> Parse (opentype.js) -> Flatten beziers -> Rasterize -> Skeletonize -> Trace -> Compute width -> Order strokes -> JSON output
```
--------------------------------
### Run Linux Text Preview E2E Tests (Docker)
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
Executes the text preview end-to-end tests using the Dockerized Playwright environment for Linux. This command requires Docker. Ensure you are in the 'packages/website' directory.
```bash
bun test:e2e:docker
```
--------------------------------
### HyperFrames Project Commands
Source: https://github.com/kurtgokhan/tegaki/blob/main/examples/hyperframes/AGENTS.md
Common commands for developing, checking, rendering, and publishing HyperFrames compositions. Use 'npm run check' after making changes to lint and validate.
```bash
npm run dev # preview in browser (studio editor)
npm run check # lint + validate + inspect
npm run render # render to MP4
npm run publish # publish and get a shareable link
npx hyperframes docs # reference docs in terminal
```
--------------------------------
### Update TegakiEngine Options
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/vanilla.mdx
Demonstrates how to dynamically update the text or effects of an existing TegakiEngine instance using the `update()` method.
```js
engine.update({ text: 'New text' });
engine.update({
effects: {
glow: { radius: 8, color: '#00ccff' },
},
});
```
--------------------------------
### Vanilla JS TegakiEngine Initialization
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/guides/rendering.mdx
Initialize the TegakiEngine in plain JavaScript to render handwriting animations. Requires a target DOM element and font bundle.
```js
import { TegakiEngine } from 'tegaki/core';
import bundle from 'tegaki/fonts/caveat';
new TegakiEngine(document.getElementById('tegaki'), {
text: 'Hello World',
font: bundle,
time: { mode: 'uncontrolled', speed: 1, loop: true },
});
```
--------------------------------
### Basic Tegaki Web Component Usage
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/web-components.mdx
Demonstrates the fundamental usage of the `` custom element with basic attributes. Styles like `font-size` and `color` are inherited by the host element.
```html
```
--------------------------------
### Run Full Check After Changes
Source: https://github.com/kurtgokhan/tegaki/blob/main/examples/hyperframes/AGENTS.md
Execute the full linting and validation process for HyperFrames compositions. This command should always be run after creating or editing composition files.
```bash
npm run check
```
--------------------------------
### Tegaki Generator File Structure
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
Overview of the directory structure for the Tegaki generator package, highlighting key modules and their functions.
```text
packages/generator/src/
index.ts # Public API exports (used by the website's in-browser pipeline)
constants.ts # Defaults: resolution (400), chars, font family (Caveat), tolerances
cli/
index.ts # CLI entry point (Padrone)
index.test.ts # Tests
commands/
generate.ts # Generate command: orchestrates the full pipeline and writes the bundle
font/
download.ts # Google Fonts download + local .ttf caching
parse.ts # opentype.js wrapper
processing/
bezier.ts # Bezier curve flattening (adaptive de Casteljau subdivision)
rasterize.ts # Scanline fill rasterizer (nonzero winding rule)
skeletonize.ts # Zhang-Suen, Guo-Hall, Lee, morphological thin, medial axis
voronoi-medial-axis.ts # Voronoi-based medial axis alternative
trace.ts # Skeleton pixel tracing + RDP simplification + spur pruning
width.ts # Distance transform for stroke width
stroke-order.ts # Connected component grouping + heuristic ordering
animated-svg.ts # Convert strokes to animated SVG + TSX
visualize.ts # Debug visualization (bitmap, skeleton, traces)
png.ts # PNG encoding
```
--------------------------------
### Applying Effects to Tegaki Renderer in SolidJS
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/solid.mdx
Demonstrates how to apply various visual effects like glow, pressure width, and stroke gradients to the animated text. Ensure the font bundle is imported.
```tsx
```
--------------------------------
### Tegaki Project Commands
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
Common commands for running the Tegaki CLI, development server, tests, and checks. These commands should be used directly without 'bun run'.
```bash
bun start # Run the CLI (generator)
bun dev # Watch mode (website)
bun run test # Run tests (all packages)
bun typecheck # TypeScript checks (all packages)
bun check # Biome lint + format check
bun fix # Biome auto-fix
bun checks # All checks: lint + format + typecheck + tests
```
--------------------------------
### Configure Tegaki Imports with Import Maps
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/web-components.mdx
Use an HTML import map to define aliases for CDN URLs, allowing for cleaner import paths similar to bundler configurations.
```html
```
--------------------------------
### Initialize GSAP Timeline for Animation
Source: https://github.com/kurtgokhan/tegaki/blob/main/examples/hyperframes/index.html
Sets up a GSAP timeline for managing animations. The timeline is initially paused and ready to be controlled.
```javascript
window.__timelines = window.__timelines || {};
window.__timelines.main = gsap.timeline({
paused: true
});
```
--------------------------------
### Unit Testing with Bun
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
Unit tests are written in .test.ts files alongside the source code and utilize Bun's built-in test runner. Import from 'bun:test' and use describe/test/expect.
```typescript
import { describe, test, expect } from 'bun:test';
describe('shaper-harfbuzz', () => {
// ... tests for splitForShaping and isShapingWhitespace ...
});
```
--------------------------------
### Vanilla JS and Web Components
Source: https://github.com/kurtgokhan/tegaki/blob/main/README.md
Import core engine for Vanilla JS or register the custom element for Web Components. Use these for non-framework environments.
```ts
import { TegakiEngine } from 'tegaki/core'; // Vanilla JS
import { registerTegakiElement } from 'tegaki/wc'; // Web Components
```
--------------------------------
### Import Default Font Bundle
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/getting-started.mdx
Import a default font bundle for use with Tegaki. This is the first step in preparing to render handwriting animations.
```tsx
import bundle from 'tegaki/fonts/caveat';
```
--------------------------------
### Streaming Text Animation with Vanilla JS
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/guides/streaming.mdx
Utilize TegakiEngine in vanilla JavaScript for streaming text. Initialize the engine with a container and font, then update the text as chunks arrive from an API.
```js
import { TegakiEngine } from 'tegaki/core';
const engine = new TegakiEngine(container, {
font: bundle,
time: { mode: 'uncontrolled', speed: 4, catchUp: 0.5 },
});
// As chunks arrive:
engine.update({ text: accumulatedText });
```
--------------------------------
### Use Tegaki from CDN via jsDelivr
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/web-components.mdx
Load Tegaki modules from jsDelivr's ESM endpoint. This method also automatically bundles dependencies.
```html
```
--------------------------------
### Update Darwin Baseline for Text Preview E2E Tests
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
Updates the local Darwin baseline snapshots for the text preview end-to-end tests. Navigate to the 'packages/website' directory before running this command.
```bash
cd packages/website && bun test:e2e:update
```
--------------------------------
### Nuxt Module Options Configuration
Source: https://github.com/kurtgokhan/tegaki/blob/main/packages/website/src/content/docs/frameworks/nuxt.mdx
Configure Tegaki module options like auto-import and component prefix in your Nuxt configuration file.
```typescript
export default defineNuxtConfig({
modules: ['tegaki/nuxt'],
tegaki: {
autoImport: true, // register globally (default: true)
prefix: '', // component name prefix (default: '')
},
});
```
--------------------------------
### Tegaki Font Bundle Structure
Source: https://github.com/kurtgokhan/tegaki/blob/main/AGENTS.md
The generate command creates a bundle directory containing the raw font file, compact glyph data, and an auto-generated TypeScript module.
```bash