0.0.4 • Published 4 years ago
@romellogoodman/flow-field v0.0.4
flow-field
A library for generating flow fields.
Demo: Codesandbox Demo
Resources for learning more about flow fields and noise:
Table of contents
Usage
Install
npm
npm i @romellogoodman/flow-fieldunpkg
<script src="https://unpkg.com/@romellogoodman/flow-field"></script>Use
import {generateField} from '@romellogoodman/flow-field';
const field = generateField({count: 100, height: 1000, width: 1000});API
generateParticles
Creates the particles for a flow field.
@param {Number} countNumber of particles in the field.@param {Number} heightHeight of space.@param {Number} marginPercent of height/width to create a padding.@param {String} seedRandom (random-js) seed.@param {Number} widthWidth of space.@return {Array}List of particle objects containing the starting x and y coordinates.
moveParticle
Computes the new position for a particle and adds it to the particle.line array.
@param {Number} amplitudeControls the range of values we get from the noise function.@param {Number} dampingSlows down the particle (think friction).@param {Number} frequencyControls how quickly/slowly the noise function is "evolving over time".@param {Number} lengthOfStepAmount to move the coordinate.@param {Object} particleParticle object containing the.@return {Void}Operates on the particle and returns nothing.
generateField
Creates a flow field with particles and lines.
@param {Number} amplitudeControls the range of values we get from the noise function. Default to5.@param {Number} countNumber of particles in the field. Default to1000.@param {Number} dampingPercentage that slows down the particle (think friction). Default to0.1.@param {Number} heightHeight of space.@param {Number} marginPercent of height/width to create a padding. Default to0.1.@param {Object} particlesList of particles to use instead of generating them.@param {String} scaleUsed to compute frequency, number of steps and step length. Default to1.@param {String} seedRandom (random-js) seed.@param {Number} widthWidth of space.@return {Array}List of particle objects containing the line coordinates.
Contributing
All contributors and all contributions both big and small are welcome in this project.