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

@spectrius/spr

v1.1.1

Published

Springs are a simple and powerful model for describing physically-based motion. **spr** is a small spring-based UI animation library.

Downloads

1

Readme

☄️ spr

Springs are a simple and powerful model for describing physically-based motion. spr is a small spring-based UI animation library.

Features

A small API

  • You should be able to animate anything by giving spr a target value and a set of animation parameters.
  • You should not have to memorize new datatypes or more than a few API calls.

Easy-to-tune motion

  • You should be able to know how an animation will look without running the game.
  • Motion is defind by frequency and damping ratio, which are easy to understand and visualize.

A robust, analytical spring model

  • You should never be able to accidentally pass the spring solver values that will cause numerical instability or explosion.
  • If spr is given a nonconverging set of motion parameters, it will throw a clear error describing what is wrong and how to fix it.

Tight integration with Roblox datatypes

  • spr animates directly over Roblox properties without additional layers of indirection.
  • spr performs runtime type checking, providing stronger typing than Roblox instance property setters.
  • spr knows how to animate in the ideal space for each datatype.
    • For example, spr will automatically animate Color3 values in perceptually-uniform CIELUV space.

Spring fundamentals

Damping ratio and undamped frequency are the two properties describing a spring's motion.

Damping ratio

  • Damping ratio < 1 overshoots and converges on the target. This is called underdamping.
  • Damping ratio = 1 converges on the target without overshooting. This is called critical damping.
  • Damping ratio > 1 converges on the target without overshooting, but slower. This is called overdamping.

Critical damping is recommended as the most visually neutral option. Underdamping is recommended for animations that need to "pop."

Damping ratio and frequency can be visualized here.

API

spr.target

spr.target(
   Instance obj,
   number dampingRatio,
   number undampedFrequency,
   table<string, Variant> targetProperties)

Animates the given properties towardes the target values, given damping ratio and frequency values.

Examples

-- damping ratio 1 (critically damped), frequency 4
-- frame quickly moves to the middle of the screen without overshooting
spr.target(frame, 1, 4, {
    Position = UDim2.fromScale(0.5, 0.5)
})
-- damping ratio 1 (critically damped), frequency 1
-- frame slowly moves to the middle of the screen without overshooting
spr.target(frame, 1, 1, {
    Position = UDim2.fromScale(0.5, 0.5)
})
-- damping ratio 0.6 (underdamped), frequency 4
-- frame quickly moves to the middle of the screen, overshoots, and wobbles around the target
spr.target(frame, 0.6, 4, {
    Position = UDim2.fromScale(0.5, 0.5)
})
-- damping ratio 0.6 (underdamped), frequency 1
-- frame slowly moves to the middle of the screen, overshoots, and wobbles around the target
spr.target(frame, 0.6, 1, {
    Position = UDim2.fromScale(0.5, 0.5)
})

spr.stop

spr.stop(
   Instance obj[,
   string property])

Stops animations for a particular property. If a property is not specified, all properties belonging to the instance will stop animating.

Examples

spr.target(frame, 0.6, 1, {
    Position = UDim2.fromScale(1, 1)
})
-- spr is now animating frame.Position

wait(1)

spr.stop(frame, "Position")
-- spr is no longer animating frame.Position
spr.target(frame, 0.6, 1, {
    Position = UDim2.fromScale(1, 1),
    Size = UDim2.fromScale(0.5, 0.5)
})
-- spr is now animating Position and Size

wait(1)

spr.stop(frame)
-- spr is no longer animating Position or Size

Setup

spr is a single-module library.

  1. Paste the source of spr.lua into a new ModuleScript
  2. Require the ModuleScript with local spr = require(<path to spr>)
  3. Follow the above code examples to get started with the API.

Documentation on how to use ModuleScripts can be found here.

roblox-ts

roblox-ts bindings for spr can be installed here.