+
Skip to content

tombigel/svg-mesh

Repository files navigation

SVG Gradient Mesh

A React library for gradient mesh emulation using SVG Voronoi surfaces and advanced SVG filters.

Live Demo: https://tombigel.github.io/svg-mesh/

Installation

git clone https://github.com/tombigel/svg-mesh.git
cd svg-mesh
npm install
npm run build:lib

Usage

import React, { useState } from 'react';
import { SvgMesh } from 'svg-mesh';

function App() {
  const [points, setPoints] = useState([
    { x: 100, y: 100, color: '#ff0000' },
    { x: 200, y: 200, color: '#00ff00' },
    { x: 300, y: 150, color: '#0000ff' },
  ]);

  return (
    <SvgMesh
      points={points}
      width={400}
      height={400}
      onPointsChange={setPoints}
      stdDeviation={40}
      slope={1}
      intercept={0}
    />
  );
}

Props

Prop Type Default Description
points Point[] required Array of points with x, y, color
width number required Canvas width
height number required Canvas height
stdDeviation number 40 Blur intensity
slope number 1 Color transfer slope
intercept number 0 Color transfer intercept
interactive boolean true Enable interaction
onPointsChange function undefined Points change callback

Point Type

type Point = {
  x: number;
  y: number;
  color: string;
};

Development

npm run dev        # Start demo
npm run build:lib  # Build library
npm run test       # Run tests
npm run deploy     # Deploy demo

License

MIT

Acknowledgments

About

A Gradient Mesh experiment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载