METADATA 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. Metadata-Version: 2.4
  2. Name: pytweening
  3. Version: 1.2.0
  4. Summary: A collection of tweening (aka easing) functions.
  5. Home-page: https://github.com/asweigart/pytweening
  6. Author: Al Sweigart
  7. Author-email: al@inventwithpython.com
  8. License: MIT
  9. Keywords: 2D animation tween tweening easing
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Environment :: Win32 (MS Windows)
  12. Classifier: Environment :: X11 Applications
  13. Classifier: Environment :: MacOS X
  14. Classifier: Intended Audience :: Developers
  15. Classifier: Operating System :: OS Independent
  16. Classifier: License :: OSI Approved :: MIT License
  17. Classifier: Programming Language :: Python
  18. Classifier: Programming Language :: Python :: 2
  19. Classifier: Programming Language :: Python :: 2.7
  20. Classifier: Programming Language :: Python :: 3
  21. Classifier: Programming Language :: Python :: 3.4
  22. Classifier: Programming Language :: Python :: 3.5
  23. Classifier: Programming Language :: Python :: 3.6
  24. Classifier: Programming Language :: Python :: 3.7
  25. Classifier: Programming Language :: Python :: 3.8
  26. Classifier: Programming Language :: Python :: 3.9
  27. Classifier: Programming Language :: Python :: 3.10
  28. Classifier: Programming Language :: Python :: 3.11
  29. Classifier: Programming Language :: Python :: 3.12
  30. Description-Content-Type: text/markdown
  31. License-File: LICENSE.txt
  32. License-File: AUTHORS.txt
  33. Dynamic: author
  34. Dynamic: author-email
  35. Dynamic: classifier
  36. Dynamic: description
  37. Dynamic: description-content-type
  38. Dynamic: home-page
  39. Dynamic: keywords
  40. Dynamic: license
  41. Dynamic: license-file
  42. Dynamic: summary
  43. PyTweening
  44. ==========
  45. A collection of tweening (aka easing) functions implemented in Python. You can learn more about it in this blog post: https://inventwithpython.com/blog/2024/02/20/make-lively-movement-animation-with-pytweenings-tweening-functions/ and in the Nordic Game Jam talk by Martin Jonasson and Petri Purho at https://youtu.be/Fy0aCDmgnxg?si=8pgITaxjJSKFyBuB&t=159
  46. Example Usage
  47. =============
  48. All tweening functions are passed an argument of a float from 0.0 (the beginning of the path) to 1.0 (the end of the path) of the tween:
  49. >>> pytweening.linear(0.5)
  50. 0.5
  51. >>> pytweening.linear(0.75)
  52. 0.75
  53. >>> pytweening.linear(1.0)
  54. 1.0
  55. >>> pytweening.easeInQuad(0.5)
  56. 0.25
  57. >>> pytweening.easeInQuad(0.75)
  58. 0.5625
  59. >>> pytweening.easeInQuad(1.0)
  60. 1.0
  61. >>> pytweening.easeInOutSine(0.75)
  62. 0.8535533905932737
  63. >>> pytweening.easeInOutSine(1.0)
  64. 1.0
  65. The getLine() function also provides a Bresenham line algorithm implementation:
  66. >>> pytweening.getLine(0, 0, 5, 10)
  67. [(0, 0), (0, 1), (1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7), (4, 8), (4, 9), (5, 10)]
  68. The getLinePoint() function finds (interpolates) a point on the given line (even if it extends before or past the start or end points):
  69. >>> getLinePoint(0, 0, 5, 10, 0.0)
  70. (0.0, 0.0)
  71. >>> getLinePoint(0, 0, 5, 10, 0.25)
  72. (1.25, 2.5)
  73. >>> getLinePoint(0, 0, 5, 10, 0.5)
  74. (2.5, 5.0)
  75. >>> getLinePoint(0, 0, 5, 10, 0.75)
  76. (3.75, 7.5)
  77. >>> getLinePoint(0, 0, 5, 10, 1.0)
  78. (5.0, 10.0)
  79. PyTweening also provides iterators to get the XY coordinates in a for loop between two points (though some floating-point rounding errors naturally occur):
  80. >>> import pytweening
  81. >>> for x, y in pytweening.iterLinear(0, 0, 100, 150, 0.1): print(x, y)
  82. ...
  83. 0.0 0.0
  84. 10.0 15.0
  85. 20.0 30.0
  86. 30.000000000000004 45.00000000000001
  87. 40.0 60.0
  88. 50.0 75.0
  89. 60.0 90.0
  90. 70.0 105.0
  91. 80.0 119.99999999999999
  92. 89.99999999999999 135.0
  93. 100.0 150.0
  94. >>> for x, y in pytweening.iterEaseOutQuad(0, 0, 100, 150, 0.1): print(x, y)
  95. ...
  96. 0.0 0.0
  97. 19.0 28.5
  98. 36.00000000000001 54.00000000000001
  99. 51.0 76.5
  100. 64.00000000000001 96.00000000000001
  101. 75.0 112.5
  102. 84.0 126.0
  103. 90.99999999999999 136.5
  104. 96.00000000000001 144.0
  105. 99.0 148.5
  106. 100.0 150.0
  107. Tweens
  108. ======
  109. pytweening.linear()
  110. ![pytweening.linear()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphLinear.png)
  111. pytweening.easeInQuad()
  112. ![pytweening.easeInQuad()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinquad.png)
  113. pytweening.easeOutQuad()
  114. ![pytweening.easeOutQuad()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutquad.png)
  115. pytweening.easeInOutQuad()
  116. ![pytweening.easeInOutQuad()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutquad.png)
  117. pytweening.easeInCubic()
  118. ![pytweening.easeInCubic()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseincubic.png)
  119. pytweening.easeOutCubic()
  120. ![pytweening.easeOutCubic()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutcubic.png)
  121. pytweening.easeInOutCubic()
  122. ![pytweening.easeInOutCubic()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutcubic.png)
  123. pytweening.easeInQuart()
  124. ![pytweening.easeInQuart()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinquart.png)
  125. pytweening.easeOutQuart()
  126. ![pytweening.easeOutQuart()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutquart.png)
  127. pytweening.easeInOutQuart()
  128. ![pytweening.easeInOutQuart()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutquart.png)
  129. pytweening.easeInQuint()
  130. ![pytweening.easeInQuint()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinquint.png)
  131. pytweening.easeOutQuint()
  132. ![pytweening.easeOutQuint()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutquint.png)
  133. pytweening.easeInOutQuint()
  134. ![pytweening.easeInOutQuint()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutquint.png)
  135. pytweening.easeInSine()
  136. ![pytweening.easeInSine()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinsine.png)
  137. pytweening.easeOutSine()
  138. ![pytweening.easeOutSine()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutsine.png)
  139. pytweening.easeInOutSine()
  140. ![pytweening.easeInOutSine()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutsine.png)
  141. pytweening.easeInExpo()
  142. ![pytweening.easeInExpo()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinexpo.png)
  143. pytweening.easeOutExpo()
  144. ![pytweening.easeOutExpo()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutexpo.png)
  145. pytweening.easeInOutExpo()
  146. ![pytweening.easeInOutExpo()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutexpo.png)
  147. pytweening.easeInCirc()
  148. ![pytweening.easeInCirc()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseincirc.png)
  149. pytweening.easeOutCirc()
  150. ![pytweening.easeOutCirc()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutcirc.png)
  151. pytweening.easeInOutCirc()
  152. ![pytweening.easeInOutCirc()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutcirc.png)
  153. pytweening.easeInElastic()
  154. ![pytweening.easeInElastic()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinelastic.png)
  155. pytweening.easeOutElastic()
  156. ![pytweening.easeOutElastic()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutelastic.png)
  157. pytweening.easeInOutElastic()
  158. ![pytweening.easeInOutElastic()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutelastic.png)
  159. pytweening.easeInBack()
  160. ![pytweening.easeInBack()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinback.png)
  161. pytweening.easeOutBack()
  162. ![pytweening.easeOutBack()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutback.png)
  163. pytweening.easeInOutBack()
  164. ![pytweening.easeInOutBack()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutback.png)
  165. pytweening.easeInBounce()
  166. ![pytweening.easeInBounce()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinbounce.png)
  167. pytweening.easeOutBounce()
  168. ![pytweening.easeOutBounce()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutbounce.png)
  169. pytweening.easeInOutBounce()
  170. ![pytweening.easeInOutBounce()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutbounce.png)
  171. pytweening.easeInPoly() (default degree of 2)
  172. ![pytweening.easeInPoly()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinpoly.png)
  173. pytweening.easeOutPoly() (default degree of 2)
  174. ![pytweening.easeOutPoly()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseoutpoly.png)
  175. pytweening.easeInOutPoly() (default degree of 2)
  176. ![pytweening.easeInOutPoly()](https://raw.githubusercontent.com/asweigart/pytweening/master/docs/tweenGraphEaseinoutpoly.png)
  177. Support
  178. -------
  179. If you find this project helpful and would like to support its development, [consider donating to its creator on Patreon](https://www.patreon.com/AlSweigart).