Detalhes do pacote

@svg-fns/types

svg-fns89MPL-2.00.0.0

Shared TypeScript type definitions for svg-fns libraries — Rect, Point, Matrix, Padding, and other geometry/layout primitives.

svg, typescript, types, geometry

readme (leia-me)

@svg-fns/types

test codecov Version Downloads npm bundle size NPM License

Shared TypeScript type definitions for the svg-fns ecosystem.
Provides minimal, reusable primitives for SVG geometry, transforms, and layout.

Install

pnpm add @svg-fns/types

(or npm install / yarn add)

Types

  • Rect{ x, y, width, height } Axis-aligned rectangle with top-left origin.

  • Point{ x, y } Cartesian 2D point.

  • Paddingnumber | { top, right, bottom, left } Uniform or per-side padding spec.

  • Matrix[a, b, c, d, e, f] Affine transform matrix matching SVGMatrix. Represents:

    [ a c e ]
    [ b d f ]
    [ 0 0 1 ]

Usage

import type { Rect, Point, Matrix, Padding } from "@svg-fns/types";

const box: Rect = { x: 0, y: 0, width: 100, height: 50 };
const center: Point = { x: 50, y: 25 };
const transform: Matrix = [1, 0, 0, 1, 10, 20];
const pad: Padding = { top: 5, right: 10, bottom: 5, left: 10 };

Motivation

  • Keep geometry types consistent across @svg-fns/* packages
  • Prevent redefinition of common shapes and matrices
  • Provide strong typing for SVG transforms, layout, and math helpers

License

This library is licensed under the MPL-2.0 open-source license.

Please enroll in our courses or sponsor our work.


with 💖 by Mayank Kumar Chaudhari