npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

p5-easing

v0.6.2

Published

Robert Penner's Easing functions for p5.js

Downloads

4

Readme

p5.easing Library

Welcome to the p5.easing library, a collection of custom easing functions for p5.js based on Robert Penner's easing equations.

Getting Started

  1. Installation:

Include it in your HTML file:

<script src="path/to/p5.easing.js"></script>
  1. Usage:

    Easing by Time Easing by time allows you to smoothly transition between values over a specified duration. Here's how to use it:

    Initialize your p5.js sketch and set up the canvas:

    // Define easing parameters
    const startTime = millis();
    const duration = 1000; // 1 second
    const startValue = 0;
    const endValue = 100;
    const easingFunction = "easeInOutQuad"; // Choose from available easing functions

    In your draw() function, use the ease() function to create animated effects:

    function draw() {
      background(220);
      let v = ease(startTime, duration, startValue, endValue, easingFunction);
      circle(width / 2, height / 2, v);
    }

    Maybe you want to update the animation parameters on mouse click:

    function mouseClicked() {
      startValue = endValue;
      endValue = random(width);
      startTime = millis();
    }

    You can experiment with different easing functions by changing the last parameter in the ease() function.

    Easing by Frames

    Easing by frames allows you to animate based on the number of frames, which is useful when rendering non-realtime animations. For instance, if you're saving your animation or working with a fixed, slow frame rate, you would use easeByFrameSteps. Here's how to use it:

    // Define easing parameters
    const startFrame = frameCount;
    const durationFrames = 60; // 1 second at 60 frames per second
    const startValue = 0;
    const endValue = 100;
    const easingFunction = "easeInOutQuad"; // Choose from available easing functions
    
    // Call the easeByFrameSteps function to get the eased value
    const easedValue = easeByFrameSteps(
      startFrame,
      durationFrames,
      startValue,
      endValue,
      easingFunction
    );

    Easing by Steps

    easeBySteps is utilized for non-linear interpolation, where the easedValue represents the interpolated value between startValue and endValue based on the currentStep and numSteps parameters. This enables achieving smooth transitions or effects in your program that are not linearly related to time.

    // Define easing parameters for non-linear interpolation
    const currentStep = stepCount; // This could represent any step value you want to interpolate
    const startStep = 0;
    const numSteps = 60; // Total number of steps
    const startValue = 0;
    const endValue = 100;
    const easingFunction = "easeInOutQuad"; // Choose from available easing functions
    
    // Call the easeBySteps function to perform non-linear interpolation
    const easedValue = easeBySteps(
      currentStep,
      startStep,
      numSteps,
      startValue,
      endValue,
      easingFunction
    );
    
    // Usage example: Non-linear interpolation
    // In this example, we use easing to interpolate a value between startValue and endValue
    // based on the currentStep and numSteps, achieving a non-linear interpolation effect.
  2. Easing Functions:

The library provides various easing functions. You can explore them using the getEasingFunctionNames() function:

console.log(getEasingFunctionNames());