MCPcopy Index your code
hub / github.com/PyQt5/PyQt / Point

Class Point

QPropertyAnimation/RlatticeEffect.py:75–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74
75class Point(QObject): # type: ignore
76 valueChanged = pyqtSignal(int)
77
78 def __init__(self, x, ox, y, oy, *args, **kwargs):
79 super(Point, self).__init__(*args, **kwargs)
80 self.__x = x
81 self._x = x
82 self.originX = ox
83 self._y = y
84 self.__y = y
85 self.originY = oy
86 # 5个闭合点
87 self.closest = [0, 0, 0, 0, 0]
88 # 圆半径
89 self.radius = 2 + random() * 2
90 # 连线颜色
91 self.lineColor = QColor(156, 217, 249)
92 # 圆颜色
93 self.circleColor = QColor(156, 217, 249)
94
95 def initAnimation(self):
96 # 属性动画
97 if not hasattr(self, "xanimation"):
98 self.xanimation = QPropertyAnimation(
99 self, b"x", self, easingCurve=QEasingCurve.InOutSine
100 )
101 self.xanimation.valueChanged.connect(self.valueChanged.emit)
102 self.yanimation = QPropertyAnimation(
103 self, b"y", self, easingCurve=QEasingCurve.InOutSine
104 )
105 self.yanimation.valueChanged.connect(self.valueChanged.emit)
106 self.yanimation.finished.connect(self.updateAnimation)
107 self.updateAnimation()
108
109 def updateAnimation(self):
110 self.xanimation.stop()
111 self.yanimation.stop()
112 duration = int((1 + random()) * 1000)
113 self.xanimation.setDuration(duration)
114 self.yanimation.setDuration(duration)
115 self.xanimation.setStartValue(self.__x)
116 self.xanimation.setEndValue(self.originX - 50 + random() * 100)
117 self.yanimation.setStartValue(self.__y)
118 self.yanimation.setEndValue(self.originY - 50 + random() * 100)
119 self.xanimation.start()
120 self.yanimation.start()
121
122 @pyqtProperty(float)
123 def x(self): # type: ignore
124 return self._x
125
126 @x.setter # type: ignore
127 def x(self, x):
128 self._x = x
129
130 @pyqtProperty(float)
131 def y(self): # type: ignore
132 return self._y

Callers 1

initPointsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected