All Projects → Fraktality → spr

Fraktality / spr

Licence: MIT license
Spring-driven motion library

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to spr

Advance
Physics-based animations for iOS, tvOS, and macOS.
Stars: ✭ 4,445 (+10237.21%)
Mutual labels:  motion, springs
plasma
A declarative, immediate mode UI widget library for Roblox.
Stars: ✭ 35 (-18.6%)
Mutual labels:  roblox
piCamBot
Security camera based on a raspberry pi and Telegram, controllable by smartphone
Stars: ✭ 43 (+0%)
Mutual labels:  motion
motion-hooks
A simple Hooks wrapper over Motion One, An animation library, built on the Web Animations API for the smallest filesize and the fastest performance.
Stars: ✭ 93 (+116.28%)
Mutual labels:  motion
room-glimpse
Read what your Raspberry Pi sees (picamera + Azure Cognitive / IoT)
Stars: ✭ 15 (-65.12%)
Mutual labels:  motion
Lua-Obfuscator
Obfuscate your lua code because it's so easy to steal!
Stars: ✭ 69 (+60.47%)
Mutual labels:  roblox
vue-motion-one
Animation library for Vue 3 based on Motion One.
Stars: ✭ 152 (+253.49%)
Mutual labels:  motion
rbx-dom
Roblox DOM and (de)serialization implementation in Rust
Stars: ✭ 76 (+76.74%)
Mutual labels:  roblox
qbot
Qbot is an advanced, easy to setup, free, and unbranded Discord-Roblox ranking bot. If at any time during setting it up you need assistance, you can join the support server.
Stars: ✭ 56 (+30.23%)
Mutual labels:  roblox
gloss
a powerful style system for building ui kits
Stars: ✭ 16 (-62.79%)
Mutual labels:  motion
interpolations
Lightweight Unity library for smoothing movements and value progressions in code (dragging, easing, tweening).
Stars: ✭ 29 (-32.56%)
Mutual labels:  motion
luacheck-roblox
Luacheck specifications for Roblox Lua
Stars: ✭ 36 (-16.28%)
Mutual labels:  roblox
Quicksave
DataStore abstraction library. Looking for a new maintainer.
Stars: ✭ 26 (-39.53%)
Mutual labels:  roblox
WebCamCap
Motion capture tool for 2D/3D motion capture with LED markers.
Stars: ✭ 20 (-53.49%)
Mutual labels:  motion
Bloxlink
Roblox Verification bot written in Python. Open-source as of 12/19/2020.
Stars: ✭ 62 (+44.19%)
Mutual labels:  roblox
roblox-js
!!!THIS PROJECT IS NO LONGER MAINTAINED!!! Execute ROBLOX website actions in node.js
Stars: ✭ 46 (+6.98%)
Mutual labels:  roblox
Roblox
Some of mine and other people's old codes that we used to run them in Script Builder.
Stars: ✭ 32 (-25.58%)
Mutual labels:  roblox
ioBroker.ring
Ring Video Doorbell Adapter
Stars: ✭ 25 (-41.86%)
Mutual labels:  motion
ux-animate
A simple but powerful tweening, spring physics, animation library for Rust
Stars: ✭ 19 (-55.81%)
Mutual labels:  motion
studio-bridge
Automatic syncing of files to Roblox Studio
Stars: ✭ 12 (-72.09%)
Mutual labels:  roblox

☄️ spr

Springs are a powerful model for describing fluid, physically-based animations. spr is a spring-based motion library for Roblox.

local spr = require(game.ReplicatedStorage.spr)

spr.target(frame, 0.6, 1, {
    Size = UDim2.fromOffset(400, 400)
})

Features

A small, easy to use API

  • spr is easy enough for designers and learning programmers to understand.
  • spr only needs a target value and motion parameters. It handles all other aspects of animation automatically and correctly, from interaction with the Roblox task scheduler to datatype-specific interpolation.

Easy-to-tune motion

  • Motion is defined by frequency and damping ratio.
  • Frequency and damping ratio are easy to visualize without running the game. Tuning usually only takes one try.

A robust spring model

  • spr's robust analytical motion solver handles a wide variety of spring parameters that cause other spring solvers to fail.
  • 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 with no overshoot. Underdamping is recommended for animations that need extra 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].