https://github.com/skyvault/tweenim
https://github.com/skyvault/tweenim
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/skyvault/tweenim
- Owner: SkyVault
- License: mit
- Created: 2022-12-17T17:52:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-02T02:00:05.000Z (over 2 years ago)
- Last Synced: 2023-03-04T05:38:56.890Z (about 2 years ago)
- Language: Nim
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tweenim - a simple tween library
## Installation
`nimble install "https://github.com/SkyVault/tweenim"`
## Example
```nim
import boxy, windy, opengl, tweenimwhen isMainModule:
let window = newWindow("dev", ivec2(1280, 720))
makeContextCurrent(window)loadExtensions()
let bxy = newBoxy()
let img = newImage(50, 50)
let ctx = newContext(img)
ctx.fillStyle = rgba(255, 255, 255, 255)
ctx.fillRoundedRect(rect(vec2(0, 0), vec2(50, 50)), 8)const duration = 20.0
var tweens = @[
newTween[float](0.0, 600.0, duration, linear),
newTween[float](0.0, 600.0, duration, inQuad),
newTween[float](0.0, 600.0, duration, outQuad),
newTween[float](0.0, 600.0, duration, inOutQuad),
newTween[float](0.0, 600.0, duration, inCubic),
newTween[float](0.0, 600.0, duration, outCubic),
newTween[float](0.0, 600.0, duration, inOutCubic),
newTween[float](0.0, 600.0, duration, inQuart),
newTween[float](0.0, 600.0, duration, outQuart),
newTween[float](0.0, 600.0, duration, inOutQuart),
newTween[float](0.0, 600.0, duration, inQuint),
newTween[float](0.0, 600.0, duration, outQuint),newTween[float](0.0, 600.0, duration, inExpo),
newTween[float](0.0, 600.0, duration, outExpo),
newTween[float](0.0, 600.0, duration, inOutExpo),newTween[float](0.0, 600.0, duration, inCirc),
newTween[float](0.0, 600.0, duration, outCirc),
newTween[float](0.0, 600.0, duration, inOutCirc),
]bxy.addImage("rect", img)
window.onFrame = proc() =
bxy.beginFrame(window.size)
var i = 0
for t in tweens.mitems:
bxy.drawImage("rect", vec2(20 + t.value, 20 + i.float * 25), tint = color(
1.0, 1.0, 0.2 + (i.float / len(tweens).float) * 0.8, 1.0))
t.update(0.1)
inc(i)
bxy.endFrame()window.swapBuffers()
while not window.closeRequested:
pollEvents()
```