New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

easing-coordinates

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easing-coordinates - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

4

dist/cjs/index.js

@@ -9,3 +9,3 @@ 'use strict'

exports.stepsCoordinates = steps_coordinates_1.stepsCoordinates
function easingCoordinates(easingFunction, steps) {
function easingCoordinates(easingFunction, polySteps) {
const errorMsgStart = `Error parsing "${easingFunction}".`

@@ -42,3 +42,3 @@ // If a shorthand like "ease-in" is provided then convert to equivalent cubic-bezier

})
return cubic_coordinates_1.cubicCoordinates(x1, y1, x2, y2, steps)
return cubic_coordinates_1.cubicCoordinates(x1, y1, x2, y2, polySteps)
}

@@ -45,0 +45,0 @@ // If it's not cubic bezier or steps it's not an easing function

@@ -98,3 +98,3 @@ 'use strict'

})
test('coordinates for "ease" with 5 steps', () => {
test('coordinates for "ease" with 5 polySteps', () => {
expect(index_1.easingCoordinates('ease', 5)).toEqual(easeTestFive)

@@ -101,0 +101,0 @@ })

'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
const Bezier = require('bezier-js')
// import { Bezier } from 'bezier-js'
// import * as Bezier from 'bezier-js'
const shared = require('./shared')
function cubicCoordinates(x1, y1, x2, y2, steps = 10) {
function points(polySteps) {
const increment = 1 / polySteps
let coordinates = []
for (let i = 0; i <= 1; i += increment) {
coordinates.push({
x: getX(i),
y: getY(i),
})
}
return coordinates
}
function getX(t, x1, x2) {
return (
(1 - t) * (1 - t) * (1 - t) * 0 +
3 * ((1 - t) * (1 - t)) * t * x1 +
3 * (1 - t) * (t * t) * x2 +
t * t * t * 1
)
}
function getY(t, y1, y2) {
return (
(1 - t) * (1 - t) * (1 - t) * 0 +
3 * ((1 - t) * (1 - t)) * t * y1 +
3 * (1 - t) * (t * t) * y2 +
t * t * t * 1
)
}
function cubicCoordinates(x1, y1, x2, y2, polySteps = 10) {
const curve = new Bezier(0, 0, x1, y1, x2, y2, 1, 1)
const coordinates = curve.getLUT(steps)
const coordinates = curve.getLUT(polySteps)
const roundedCoordinates = coordinates.map(obj => shared.getCoordinate(obj.x, obj.y))

@@ -11,0 +35,0 @@ return roundedCoordinates

@@ -11,3 +11,3 @@ 'use strict'

const convertToNumberMaybe = str => (Number.isNaN(Number(str)) ? str : Number(str))
const roundToMaxTenDecimals = num => Number(`${+num.toFixed(10)}`)
const roundToMaxTenDecimals = num => +num.toFixed(10)
exports.getCoordinate = (x, y) => {

@@ -14,0 +14,0 @@ return {

import { cubicCoordinates } from './lib/cubic-coordinates'
import * as shared from './lib/shared'
import { stepsCoordinates } from './lib/steps-coordinates'
declare function easingCoordinates(easingFunction: string, steps?: number): shared.ICoordinate[]
declare function easingCoordinates(easingFunction: string, polySteps?: number): shared.ICoordinate[]
export { stepsCoordinates, cubicCoordinates, easingCoordinates, easingCoordinates as default }

@@ -5,3 +5,3 @@ import { cubicCoordinates } from './lib/cubic-coordinates'

import { stepsCoordinates } from './lib/steps-coordinates'
function easingCoordinates(easingFunction, steps) {
function easingCoordinates(easingFunction, polySteps) {
const errorMsgStart = `Error parsing "${easingFunction}".`

@@ -38,3 +38,3 @@ // If a shorthand like "ease-in" is provided then convert to equivalent cubic-bezier

})
return cubicCoordinates(x1, y1, x2, y2, steps)
return cubicCoordinates(x1, y1, x2, y2, polySteps)
}

@@ -41,0 +41,0 @@ // If it's not cubic bezier or steps it's not an easing function

@@ -96,3 +96,3 @@ import { cubicCoordinates, easingCoordinates, stepsCoordinates } from './index'

})
test('coordinates for "ease" with 5 steps', () => {
test('coordinates for "ease" with 5 polySteps', () => {
expect(easingCoordinates('ease', 5)).toEqual(easeTestFive)

@@ -99,0 +99,0 @@ })

@@ -7,3 +7,3 @@ import * as shared from './shared'

y2: number,
steps?: number
polySteps?: number
): shared.ICoordinate[]

@@ -1,10 +0,34 @@

const Bezier = require('bezier-js')
// import { Bezier } from 'bezier-js'
// import * as Bezier from 'bezier-js'
import * as shared from './shared'
export function cubicCoordinates(x1, y1, x2, y2, steps = 10) {
function points(polySteps) {
const increment = 1 / polySteps
let coordinates = []
for (let i = 0; i <= 1; i += increment) {
coordinates.push({
x: getX(i),
y: getY(i),
})
}
return coordinates
}
function getX(t, x1, x2) {
return (
(1 - t) * (1 - t) * (1 - t) * 0 +
3 * ((1 - t) * (1 - t)) * t * x1 +
3 * (1 - t) * (t * t) * x2 +
t * t * t * 1
)
}
function getY(t, y1, y2) {
return (
(1 - t) * (1 - t) * (1 - t) * 0 +
3 * ((1 - t) * (1 - t)) * t * y1 +
3 * (1 - t) * (t * t) * y2 +
t * t * t * 1
)
}
export function cubicCoordinates(x1, y1, x2, y2, polySteps = 10) {
const curve = new Bezier(0, 0, x1, y1, x2, y2, 1, 1)
const coordinates = curve.getLUT(steps)
const coordinates = curve.getLUT(polySteps)
const roundedCoordinates = coordinates.map(obj => shared.getCoordinate(obj.x, obj.y))
return roundedCoordinates
}

@@ -9,3 +9,3 @@ const getParenthesisContent = str => {

const convertToNumberMaybe = str => (Number.isNaN(Number(str)) ? str : Number(str))
const roundToMaxTenDecimals = num => Number(`${+num.toFixed(10)}`)
const roundToMaxTenDecimals = num => +num.toFixed(10)
export const getCoordinate = (x, y) => {

@@ -12,0 +12,0 @@ return {

{
"name": "easing-coordinates",
"version": "2.0.0",
"description":
"Utility script that takes an easing function as input and outputs a coordinate set with adjustable precision/resolution.",
"version": "2.0.1",
"description": "Utility script that takes an easing function as input and outputs a coordinate set with adjustable precision/resolution.",
"repository": {

@@ -10,3 +9,5 @@ "type": "git",

},
"files": ["dist"],
"files": [
"dist"
],
"main": "dist/cjs/index.js",

@@ -25,7 +26,9 @@ "module": "dist/index.js",

"test": "jest",
"test-ci":
"jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"test-ci": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"coverage": "jest --coverage"
},
"keywords": ["easing-functions", "javascript"],
"keywords": [
"easing-functions",
"javascript"
],
"author": "larsenwork <andreas@larsenwork.com> (https://larsenwork.com)",

@@ -36,18 +39,15 @@ "license": "MIT",

},
"dependencies": {
"@types/bezier-js": "0.0.7",
"bezier-js": "^2.2.5"
},
"dependencies": {},
"homepage": "https://larsenwork.com/easing-gradients/",
"devDependencies": {
"@types/jest": "^22.2.3",
"coveralls": "^3.0.1",
"husky": "^1.0.0-rc.7",
"jest": "^23.0.0",
"prettier": "^1.12.1",
"pretty-quick": "^1.6.0",
"ts-jest": "^22.4.6",
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.13.0",
"typescript": "^2.8.3"
"@types/jest": "^23.3.2",
"coveralls": "^3.0.2",
"husky": "^1.0.0-rc.15",
"jest": "^23.6.0",
"prettier": "^1.14.3",
"pretty-quick": "^1.7.0",
"ts-jest": "^23.10.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"typescript": "^3.0.3"
},

@@ -54,0 +54,0 @@ "husky": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc