Skip to content

awenine/node-graph-envelope-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-graph-envelope-js

A function for creating a graph function from defined node points in Javascript

The Problem

Similar to the envelope mapping found in animation software, this library allows you to create different 'envelope map' functions, that map an input value to an output value, based on a graph defined by nodes/keyframes.

Usage

Define an array of node for the graph, which are objects that comprise an input (corresponding to the input passed into the graph; the x value) and a value (what the value should be at that point; the y value)

const envelopeNodes = [
	{
		input: 0,
		value: 0.6,
	},
	{
		input: 10,
		value: 1,
	},
	{
		input: 30,
		value: 0.75,
	},
	{
		input: 40,
		value: 0,
	},
	{
		input: 80,
		value: 0.2,
	},
];

Then call the createGraph() function passing these nodes, which will return a function that can be used to calculate the value of the graph at any point

Examples

  • controlling animation
  • controlling audio parameters

Caveats

  • currently only produces straight lines between the nodes; curves/handles are yet to be implemented

About

A function for creating a graph function from defined node points in Javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published