当前位置:网站首页>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_())边栏推荐
- HCIP - MPLS VPN experiment
- 代码随想录笔记_哈希_202 快乐数
- Jenkins 如何玩转接口自动化测试?
- MySQL [operator]
- Apache DolphinScheduler新一代分布式工作流任务调度平台实战-上
- conda 导出/导出配置好的虚拟环境
- Unity性能分析 Unity Profile性能分析工具
- Using IN in MySQL will not go through index analysis and solutions
- Concise Notes on Integrals - Types of Curve Integrals of the Second Kind
- qsort 函数的使用及其模拟实现
猜你喜欢

How to avoid CMDB becoming a data island?

MySQL Explain 使用及参数详解

pnpm简介

日志导致线程Block的这些坑,你不得不防

初识Apifox——如何使用Apifox做一个简单的接口测试

【 HMS core 】 【 】 the FAQ HMS Toolkit collection of typical questions 1

功能测试、UI自动化测试(web自动化测试)、接口自动化测试

Devops和低代码的故事:螳螂捕蝉,黄雀在后

Access to display the data

Taosi TDengine 2.6+ optimization parameters
随机推荐
Windows 下安装 MySQL
【云原生】Kubernetes入门详细讲解
深入浅出零钱兑换问题——背包问题的套壳
一文理解分布式开发中的服务治理
HCIP - MPLS VPN experiment
积分专题笔记-曲线面积分三大公式
MySQL数据库题库
使用 Neuron 接入 Modbus TCP 及 Modbus RTU 协议设备
Oracle 创建和操作表
Is R&D moving to FAE (Field Application Engineer), is it moving away from technology?Is there a future?
团队级敏捷真的没你想的那么简单
Functional Interfaces & Lambda Expressions - Simple Application Notes
2022 Hangzhou Electric Multi-School 1st Game
It is said that FPGA is high-end, what can it do?
leetcode 剑指 Offer 10- I. 斐波那契数列
How to implement Golang DES encryption and decryption?
CSDN21天学习挑战赛
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-上
硬件工程师
包、类及四大权限和static