+
Skip to content

taKana671/pytweener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pytweener

This repository provides easing functions implemented in Python.
I decided to try creative coding with Python and Panda3D, and first created the modules that provide these easing functions as a means to smoothly move animation. For a demonstration, please see ParticleText.

Requirements

  • Panda3D 1.10.15
  • numpy 2.2.4

Environment

  • Python 3.12
  • Windows11

Usage

Instantiate the Tween class

tween = Tween(start, end, duration, delay=0, yoyo=False, easing_type='linear')

parameters

start and end can be specified as a scalar, numpy.ndarray, panda3d.core.Point2, Point3, Vec2, Vec3 and so on.

  • start: float

    • The start point of the animation.
  • end: float

    • The end point of the animation.
  • duration: int

    • The time that an animation takes to complete. Specify in seconds.
  • delay: float

    • Start delay time.
  • yoyo: bool

    • If True, go to the end point and come back. If False, just go to the end point. The default is False.
  • easing_type: string

    • The function name defined in the Ease class. The default is linear.

Basic Usage

After instantiating the Tween class, call the start method. The instance variable is_playing is set to True when the animation starts and changes to False when it ends, and the next move position of the 3D model, etc. is stored in the instance variable next_pos after the update method is called.

from panda3d.core import Point3

from pytweener.tween import Tween

tween = Tween(Point3(0.5, 0.5, 0.5), Point3(3.5, 1.5, 3.5), 2.0, delay=0, yoyo=True, easing_type='in_out_expo')
tween.start()

while True:

    if tween.is_playing:
        tween.update()
        print(tween.next_pos)
    else:
        break

Loop the animation.

# If the number of repeats is not specified, it loops infinitely.
tween.loop()

# The number of repeats is specified as follows.
#tween.loop(repeats=3)

Temporarily pause and resume the animation.

tween.pause()
tween.resume()

Stop the animation and move its state to its final state.

tween.finish()

References

The easing functions are based on below.

About

Provides easing functions implemented in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载