-
大小: 1.79MB文件類型: .zip金幣: 2下載: 0 次發布日期: 2023-11-18
- 語言: Python
- 標簽:
資源簡介
用pyqt5和parametrics實現很酷的動畫

代碼片段和文件信息
#!/usr/bin/env?python3
from?math?import?sin?cos?radians
import?sys
from?os?import?path?remove
from?time?import?sleep
from?PyQt5.QtGui?import?QPainter?QPalette?QPen?QColor?QBrush?QIcon
from?PyQt5.QtWidgets?import?(QWidget?QHBoxLayout?QVBoxLayout?QFormLayout
?????????????????????????????QSizePolicy?QApplication?QSlider?QLabel
?????????????????????????????QPushButton?QCheckBox?QFileDialog?QMessageBox
?????????????????????????????QProgressDialog?QColorDialog)
from?PyQt5.QtCore?import?(QSize?QTimer?QPointF?Qt?QLineF?QByteArray
??????????????????????????QBuffer?QIODevice)
EXPORT_AVAILABLE?=?True
try:
????import?imageio
except?ImportError:
????print(“Animation?video?export?will?be?unavailable?because?you?are?missing?imageio?module“)
????EXPORT_AVAILABLE?=?False
#?Default?values?of?various?options
X_MULT_DEF?=?1
Y_MULT_DEF?=?1
DOT_SIZE_DEF?=?6
NUM_DOTS_DEF?=?40
ANGLE_FACTOR_DEF?=?360
HALFMAX_DEF?=?180
SPEED_MULT_DEF?=?3
DELAY_DEF?=?35
AXES_DEF?=?False
JOIN_ENDS_DEF?=?False
DRAW_AXES_DEF?=?False
COL1_DEF?=?QColor.fromRgb(0?180?0)
COL2_DEF?=?QColor.fromRgb(0?0?180)
LINES_DEF?=?False
CONNECT_LINES_DEF?=?False
def?resource_path(relative_path):
????“““
????Get?absolute?path?to?resource?works?for?dev?and?PyInstaller?binary
????https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile
????“““
????try:
????????#?PyInstaller?creates?a?temp?folder?and?stores?path?in?_MEIPASS
????????base_path?=?sys._MEIPASS
????except?AttributeError:
????????base_path?=?path.abspath(“.“)
????return?path.join(base_path?relative_path)
def?interpolate_hsv(col1?col2?num_middle):
????“““
????find?colours?in?between?the?two?and?yield?QColors?including?original?colours
????expects?QColors?returns?QColors?from?col1?to?col2
????expects?alpha?to?always?be?255
????“““
????if?num_middle?0:
????????raise?ValueError
????assert?col1.isValid()
????assert?col2.isValid()
????start_h?=?col1.hsvHue()?%?360
????start_s?=?col1.hsvSaturation()?%?256
????start_v?=?col1.value()?%?256
????delta_h?=?(col2.hsvHue()?%?360)?-?start_h
????#?https://stackoverflow.com/questions/2593832/
????#?how-to-interpolate-hue-values-in-hsv-colour-space
????#?Can?be?+?or?-?and?magnitude?can?be?>?180?or?180
????if?delta_h?-180:
????????#?Between?-360?and?-180
????????#?eg?10?-?300?=?-290
????????#?we?should?go?the?other?way?around
????????#?eg?70
????????delta_h?=?360?+?delta_h
????elif?delta_h?>?180:
????????#?delta?h?between?180?and?360?we?should?go?the?other?way?around
????????delta_h?=?-?360?+?delta_h
????delta_s?=?(col2.hsvSaturation()?%?256)?-?start_s
????delta_v?=?(col2.value()?%?256)?-?start_v
????yield?col1
????for?i?in?range(1?num_middle+1):
????????frac?=?i/num_middle
????????yield?QColor.fromHsv(
????????????(start_h?+?delta_h*frac)?%?360
????????????(start_s?+?delta_s*frac)?%?256
????????????(start_v?+?delta_v*frac)?%?256
????????)
????yield?col2
class?DotsWidget(QWidget):
????“““A?custom?widget?for?animating?dots“““
????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-06-12?00:50??captivox-master\
?????文件??????????53??2019-06-12?00:50??captivox-master\.gitignore
?????文件?????????683??2019-06-12?00:50??captivox-master\.travis.yml
?????文件???????35147??2019-06-12?00:50??captivox-master\LICENSE
?????文件????????2053??2019-06-12?00:50??captivox-master\README.md
?????文件?????1875785??2019-06-12?00:50??captivox-master\captivox.gif
?????文件???????24337??2019-06-12?00:50??captivox-master\captivox.py
?????文件????????4504??2019-06-12?00:50??captivox-master\icon.png
?????文件??????????14??2019-06-12?00:50??captivox-master\requirements.txt
評論
共有 條評論