Use QPointF instead of QPoint for float input

This commit is contained in:
Ogi Moore 2021-02-12 13:30:06 -08:00
parent f853d8b520
commit 955f1c37a6

View File

@ -54,9 +54,12 @@ class JoystickButton(QtGui.QPushButton):
d = (d / self.radius) ** 2
xy = [nxy[0] * d, nxy[1] * d]
w2 = self.width()/2.
w2 = self.width() / 2
h2 = self.height() / 2
self.spotPos = QtCore.QPoint(w2*(1+xy[0]), h2*(1-xy[1]))
self.spotPos = QtCore.QPoint(
int(w2 * (1 + xy[0])),
int(h2 * (1 - xy[1]))
)
self.update()
if self.state == xy:
return
@ -67,7 +70,12 @@ class JoystickButton(QtGui.QPushButton):
super().paintEvent(ev)
p = QtGui.QPainter(self)
p.setBrush(QtGui.QBrush(QtGui.QColor(0,0,0)))
p.drawEllipse(self.spotPos.x()-3,self.spotPos.y()-3,6,6)
p.drawEllipse(
self.spotPos.x() - 3,
self.spotPos.y() - 3,
6,
6
)
def resizeEvent(self, ev):
self.setState(*self.state)