当前位置:网站首页>PyQt5-用像素点绘制正弦曲线
PyQt5-用像素点绘制正弦曲线
2022-07-30 09:05:00 【獜洛橙】
效果如下:

代码如下:
'''
用像素点绘制正弦曲线
-2PI 2PI
drawPoint(x,y)
'''
import sys,math
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import Qt
class DrawPoints(QWidget):
def __init__(self):
super(DrawPoints,self).__init__()
self.resize(300,300)
self.setWindowTitle('在窗口上用像素点绘制2个周期的正弦曲线')
def paintEvent(self, event):
painter = QPainter()
painter.begin(self)
painter.setPen(Qt.blue)
size = self.size()
for i in range(1000):
x = 100 * (-1 + 2.0 * i/1000) + size.width()/2.0
y = -50 * math.sin((x - size.width()/2.0) * math.pi/50) + size.height()/2.0
painter.drawPoint(x,y)
painter.end()
if __name__ == '__main__':
app = QApplication(sys.argv)
main = DrawPoints()
main.show()
sys.exit(app.exec_())边栏推荐
- [Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers
- 微软 SQL 服务器被黑,带宽遭到破坏
- PyTorch安装及环境配置(Win10)
- C# 之 $ – 字符串内插
- Unity性能分析 Unity Profile性能分析工具
- 快解析结合象过河erp
- 编程界的“躲猫猫”比赛 | 每日趣闻
- EMC过不了?都是PCB工程师的锅?
- [Fun BLDC series with zero basics] Taking GD32F30x as an example, the timer related functions are explained in detail
- conda 导出/导出配置好的虚拟环境
猜你喜欢

虚幻引擎图文笔记:could not be compiled. Try rebuilding from source manually.问题的解决

新手必备!最全电路基础知识讲解

The use of qsort function and its analog implementation

Apache DolphinScheduler新一代分布式工作流任务调度平台实战-上

柱状图 直方图 条形图 的区别

Using IN in MySQL will not go through index analysis and solutions

积分专题笔记-曲线面积分三大公式

Windows 下安装 MySQL

瑞吉外卖项目(五) 菜品管理业务开发

【 HMS core 】 【 】 the FAQ HMS Toolkit collection of typical questions 1
随机推荐
HR团队如何提升效率?人力资源RPA给你答案
百度paddleocr检测训练
An article to understand service governance in distributed development
leetcode 剑指 Offer 10- II. 青蛙跳台阶问题
C#中Config文件中,密码的 特殊符号的书写方法。
Network/Information Security Top Journal and Related Journals Conference
七大排序之直接选择排序
MySQL【运算符】
iperf3 参数选项详细说明
Unable to locate the program input point ucrtbase.abort on the dynamic link library api-ms-win-crt-runtime-|1-1-0.dll
The R installation package has error in rawtochar(block[seq_len(ns)]) :
C# 之 $ – 字符串内插
涛思 TDengine 2.6+优化参数
Circuit analysis: constant current source circuit composed of op amp and triode
【无标题】
使用 Neuron 接入 Modbus TCP 及 Modbus RTU 协议设备
Unity performance analysis Unity Profile performance analysis tool
Integral Special Notes - Definition of Integral
快解析结合泛微OA
PyQt5快速开发与实战 8.1 窗口风格