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

Method animate

QPropertyAnimation/RlatticeEffect.py:187–230  ·  view source on GitHub ↗
(self, painter)

Source from the content-addressed store, hash-verified

185 print(time() - t)
186
187 def animate(self, painter):
188 for p in self.points:
189 # 检测点的范围
190 value = abs(getDistance(self.target, p))
191 if value < 4000:
192 # 其实就是修改颜色透明度
193 p.lineColor.setAlphaF(0.3)
194 p.circleColor.setAlphaF(0.6)
195 elif value < 20000:
196 p.lineColor.setAlphaF(0.1)
197 p.circleColor.setAlphaF(0.3)
198 elif value < 40000:
199 p.lineColor.setAlphaF(0.02)
200 p.circleColor.setAlphaF(0.1)
201 else:
202 p.lineColor.setAlphaF(0)
203 p.circleColor.setAlphaF(0)
204
205 # 画线条
206 if p.lineColor.alpha():
207 for pc in p.closest:
208 if not pc:
209 continue
210 path = QPainterPath()
211 path.moveTo(p.x, p.y)
212 path.lineTo(pc.x, pc.y)
213 painter.save()
214 painter.setPen(p.lineColor)
215 painter.drawPath(path)
216 painter.restore()
217
218 # 画圆
219 painter.save()
220 painter.setPen(Qt.NoPen)
221 painter.setBrush(p.circleColor)
222 painter.drawRoundedRect(
223 QRectF(p.x - p.radius, p.y - p.radius, 2 * p.radius, 2 * p.radius),
224 p.radius,
225 p.radius,
226 )
227 painter.restore()
228
229 # 开启动画
230 p.initAnimation()
231
232
233if __name__ == "__main__":

Callers 3

paintEventMethod · 0.95
jquery.jsFile · 0.80
jquery.jsFile · 0.80

Calls 5

setPenMethod · 0.80
restoreMethod · 0.80
setBrushMethod · 0.80
getDistanceFunction · 0.70
initAnimationMethod · 0.45

Tested by

no test coverage detected