0.13.1 • Published 4 months ago

@use-gpu/glyph v0.13.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

@use-gpu/glyph

npm install --save @use-gpu/glyph
yarn add @use-gpu/glyph

Docs: https://usegpu.live/docs/reference-library-@use-gpu-glyph

Use.GPU - SDF + Font glyph renderer

  • rust/wasm ab_glyph wrapper
  • subpixel distance transform in TS

Stand-alone SDF:

import { glyphToSDF, rgbaToSDF } from '@use-gpu/glyph/sdf';
// Convert grayscale glyph to SDF
glyphToSDF = (
  data: Uint8Array,
  w: number,
  h: number,
  pad: number = 4,
  radius: number = 3,
  cutoff: number = 0.25,

  // ESDT vs EDT
  subpixel: boolean = true,

  // Solidify semi-transparent areas
  solidify: boolean = true,

  // Pre-process contour
  preprocess: boolean = false,

  // Post-process SDF
  postprocess: boolean = false,

  // Get intermediate steps
  debug?: (image: Image) => void,
): Image;

// Convert RGBA image to SDF
rgbaToSDF = (
  data: Uint8Array,
  w: number,
  h: number,
  pad: number = 4,
  radius: number = 3,
  cutoff: number = 0.25,
  subpixel: boolean = true,
  solidify: boolean = true,
  preprocess: boolean = false,
  postprocess: boolean = false,
  debug?: (image: Image) => void,
): Image;

type Image = {
  data: Uint8Array,
  width: number,
  height: number,
};

Colofon

Made by Steven Wittens. Part of @use-gpu.

0.13.0

5 months ago

0.13.1

4 months ago

0.12.0

10 months ago

0.11.3

11 months ago

0.11.1

12 months ago

0.11.0

1 year ago

0.9.3

2 years ago

0.10.1

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.8.4

2 years ago

0.8.3

2 years ago

0.8.0

2 years ago

0.7.0

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago