-
大小: 1.79MB文件类型: .zip金币: 1下载: 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
相关资源
- Python-在线网络小说搜索阅读网站
- Python-Camelot一个可以轻松地从PDF文件中
- Python-一个用手势控制的计算器
- Python-最全中华古诗词数据库
- Python-导出qq音乐歌单的小工具导出格
- Python-利用keras模仿汪峰生成歌词
- Python-洛谷冬日绘板脚本
- Python-PermaNote是基于Sandstorm开源的个人
- Python-当朋友给你发iMessage时自动回复
- Python-中国县级行政区划的边界数据并
- Python-垃圾分类助手猜测可能是什么垃
- Python-csv2tex将csv数据变成LaTeX表格
- Python-这是一个DSStore文件泄漏利用脚本
- Python-基于itchat库和图灵机器人实现的
- Python-农业知识图谱农业领域的命名实
- Python-从Python高效处理FASTQ文件
- Python-一个WindowsLinux和Mac的简单键盘记
- Python-Binance虚拟货币交易机器人
- Python-AWDHunter一个基于Python27的AWD自动
- Python-ArkNights自动作战脚本
- Python-导出安卓微信聊天数据工具
- Python-这是一个简单的Web聊天系统可以
评论
共有 条评论