当前位置:网站首页>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_())边栏推荐
- Only after such a stage of development can digital retail have a new evolution
- leetcode 剑指 Offer 48. 最长不含重复字符的子字符串
- Unreal Engine Graphic Notes: could not be compiled. Try rebuilding from source manually. Problem solving
- Functional Interfaces & Lambda Expressions - Simple Application Notes
- leetcode 剑指 Offer 25. 合并两个排序的链表
- An article to understand service governance in distributed development
- Is R&D moving to FAE (Field Application Engineer), is it moving away from technology?Is there a future?
- 2022杭电多校第一场
- C#中Config文件中,密码的 特殊符号的书写方法。
- 分布式系统大势所趋,银行运维如何与时俱进?
猜你喜欢

leetcode 剑指 Offer 12. 矩阵中的路径

统一异常处理导致ResponseBodyAdvice失效

快解析结合任我行crm

HCIP - MPLS VPN experiment

leetcode 剑指 Offer 52. 两个链表的第一个公共节点

C language classic practice questions (3) - "Hanoi Tower (Hanoi)"

分布式系统大势所趋,银行运维如何与时俱进?

Jenkins 如何玩转接口自动化测试?

Explain the problem of change exchange in simple terms - the shell of the backpack problem
![[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers](/img/ff/f3de4952d64afe36c515a2220bfe9d.png)
[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers
随机推荐
Circuit analysis: constant current source circuit composed of op amp and triode
Version management of public Jar packages
【云原生】Kubernetes入门详细讲解
leetcode 剑指 Offer 15. 二进制中1的个数
20220728使用电脑上的蓝牙和汇承科技的蓝牙模块HC-05配对蓝牙串口传输
功能测试、UI自动化测试(web自动化测试)、接口自动化测试
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-上
积分专题笔记-与路径无关条件
leetcode 剑指 Offer 10- I. 斐波那契数列
Google Cloud Spanner的实践经验
0729放假自习
2022 Hangzhou Electric Multi-School 2nd Game
知识图谱之Cypher语言的使用
Unity性能分析 Unity Profile性能分析工具
[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers
用示波器揭示以太网传输机制
Concise Notes on Integrals - Types of Curve Integrals of the First Kind
激活数据潜力 亚马逊云科技重塑云上存储“全家桶”
els 方块、背景上色
69. Sqrt(x)x 的平方根