use-gradient-effector

1.1.0 • Public • Published

use-gradient-effector

Modify a matrix of values with an offscreen gradient. Inspired by Cinema 4D's shader effector, which can trigger transformations depending on the shader's value at a coordinate.

NPM JavaScript Style Guide

Install

npm install --save use-gradient-effector

Usage

import React, { Component } from 'react'

import { useGradientEffector } from 'use-gradient-effector'

const Example = () => {

  const shaderOutput = useGradientEffector({
    dimensions, // Object with DOM element's dimensions:  { width: number, height: number }
    position, // Coordinate to center gradient, useful for mouse or element position
    columns: 8, // Number of columns
    rows: 6 // Number of rows
  });
  console.log(shaderOutput)
  return (
    <div>{example}</div>
  )
}

Todo

  • Add noise layer and multiplier
  • Make use of other channels for layers
  • Add linear/radial argument

License

MIT © zray


This hook is created using create-react-hook.

Dependents (0)

Package Sidebar

Install

npm i use-gradient-effector

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

161 kB

Total Files

24

Last publish

Collaborators

  • zray