Neat

Build awesome gradients for your website, using 3d shaders

README

Neat gradients


Create awesome 3d gradients with this library based on three.js.

Check the demo and gradients editor to find your perfect config here:

Neat is released under the CC license, so you can use it for free in your
projects,
commercial or not. You can also modify it and redistribute it, but you must keep
the license and the credits.

If you want to remove the Camberi link, you can reach us at hello@firecms.co

Installation:


  1. ```
  2. yarn install @firecms/neat three.js
  3. ```

or

  1. ```
  2. npm install @firecms/neat three.js
  3. ```

Usage:


  1. ```typescript
  2. import { NeatConfig, NeatGradient } from "@firecms/neat";

  3. // Define your config
  4. export const config: NeatConfig = {
  5.     colors: [
  6.         {
  7.             color: "#FF5373",
  8.             enabled: true
  9.         },
  10.         {
  11.             color: "#FFC858",
  12.             enabled: true
  13.         },
  14.         {
  15.             color: "#17E7FF",
  16.             enabled: true
  17.         },
  18.         {
  19.             color: "#6D3BFF",
  20.             enabled: true
  21.         },
  22.         {
  23.             color: "#f5e1e5",
  24.             enabled: false
  25.         }
  26.     ],
  27.     speed: 4,
  28.     horizontalPressure: 4,
  29.     verticalPressure: 5,
  30.     waveFrequencyX: 2,
  31.     waveFrequencyY: 3,
  32.     waveAmplitude: 5,
  33.     shadows: 0,
  34.     highlights: 2,
  35.     saturation: 7,
  36.     wireframe: false,
  37.     colorBlending: 6,
  38.     backgroundColor: "#003FFF",
  39.     backgroundAlpha: 1
  40. };


  41. // define an element with id="gradient" in your html
  42. const neat = new NeatGradient({
  43.     ref: document.getElementById("gradient"),
  44.     ...config
  45. });

  46. // you can change the config at any time
  47. neat.speed = 6;

  48. // you can also destroy the gradient for cleanup
  49. // e.g. returning from a useEffect hook in React
  50. neat.destroy();
  51. ```

How it works


Neat is a three.js library that generates a 3d gradient based on a config
object.

It uses a custom WebGL shader to generate a 3D shape that morphs and changes
its color based on the config.

All the computations are done on the GPU, so it's very fast and efficient.