1 Star 0 Fork 1

没什么好笑的/automatic_clicker_New_UI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
场景.py 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
import math
from PySide6.QtCore import QRectF, QLine
from PySide6.QtGui import QColor, QPen, QPainter
from PySide6.QtWidgets import QGraphicsScene
class QDMGraphicsScene(QGraphicsScene):
def __init__(self, parent=None):
super().__init__(parent)
# self.scene = scene
# settings
self.grid_size = 20
self.grid_square = 4
self._color_background = QColor('#2E2E2E') # Darker gray for background
self._color_light = QColor('#4F4F4F') # Slightly lighter gray
self._color_dark = QColor('#000000') # Slightly darker gray
# Create pens
self._pen_light = QPen(self._color_light)
self._pen_light.setWidth(1)
self._pen_dark = QPen(self._color_dark)
self._pen_dark.setWidth(2)
# Set background color
self.setBackgroundBrush(self._color_background)
def setScene(self, width: float, height: float):
self.setSceneRect(-width // 2, -height // 2, width, height)
def drawBackground(self, painter: QPainter, rect: QRectF) -> None:
super().drawBackground(painter, rect)
# create grid
left = int(math.floor(rect.left()))
right = int(math.floor(rect.right()))
top = int(math.floor(rect.top()))
bottom = int(math.floor(rect.bottom()))
# compute all lines
first_left = left - (left % self.grid_size)
first_top = top - (top % self.grid_size)
lines_light, lines_dark = [], []
for x in range(first_left, right, self.grid_size):
if x % (self.grid_size * self.grid_square) == 0:
lines_dark.append(QLine(x, top, x, bottom))
else:
lines_light.append(QLine(x, top, x, bottom))
for y in range(first_top, bottom, self.grid_size):
if y % (self.grid_size * self.grid_square) == 0:
lines_dark.append(QLine(left, y, right, y))
else:
lines_light.append(QLine(left, y, right, y))
# draw lines
painter.setPen(self._pen_light)
painter.drawLines(lines_light)
painter.setPen(self._pen_dark)
painter.drawLines(lines_dark)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/xintao/automatic_clicker_-new_-ui.git
git@gitee.com:xintao/automatic_clicker_-new_-ui.git
xintao
automatic_clicker_-new_-ui
automatic_clicker_New_UI
master

搜索帮助