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

cubic-bezier-object

v1.0.2

Published

三次贝塞尔对象

Downloads

9

Readme

CubicBezier

三次贝塞尔曲线求值

安装

$ npm install cubic-bezier-object

创建一个三次贝塞尔曲线对象

/**
 * 创建一个三次贝塞尔对象
 * 每一个参数为一个表示点的数组[x,y],或者一个Point对象
 * @param {Array|Point} c1    表示起始点的控制点
 * @param {Array|Point} c2    表示结束点的控制点
 * @param {Array|Point} begin 可选。表示起始点,默认为[0,0]
 * @param {Array|Point} end   可选。表示结束点,默认为[1,1]
 */
var cubicBezier = new CubicBezier([.175, .885], [.32, 1.275]);

直接用三次贝塞尔表达式创建

/**
 * 三次贝塞尔表达式创建
 * @param {String}      easing 三次贝塞尔表达式
 * @param {Array|Point} begin  可选。表示起始点,默认为[0,0]
 * @param {Array|Point} end    可选。表示结束点,默认为[1,1]
 */
var cubicBezier = new CubicBezier('cubic-bezier(.175, .885,.32,1.275)');

已知y,求x

/**
 * 已知y,求x
 * @param  {number} y 参数表示一个在贝塞尔曲线上Y轴方向的向量,取值在 0.0 - 1.0 之间
 * @return            返回y在贝塞尔曲线上对应的x
 */
cubicBezier.getX(y);

已知x,求y

/**
 * 已知x,求y
 * @param  {number} x 参数表示一个在贝塞尔曲线上X轴方向的向量,取值在 0.0 - 1.0 之间
 * @return            返回x在贝塞尔曲线上对应的y
 */
cubicBezier.getY(x);

根据时间获取曲线上对应的点

/**
 * 根据时间获取曲线上对应的点
 * @param  {number} t 参数表示一个 0.0 - 1.0 的时间向量
 * @return            返回的结果是该时刻在贝塞尔曲线上的点
 */
cubicBezier.getPoint(t);

设置一个新的贝塞尔函数

/**
 * 设置一个新的贝塞尔函数
 * 参数与构造函数相同
 */
cubicBezier.set(c1, c2, begin, end);

创建一个Point对象

var point = new CubicBezier.Point(x, y);