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

Method renderPoints

Demo/CircleLine.py:220–257  ·  view source on GitHub ↗
(self, painter, circles)

Source from the content-addressed store, hash-verified

218 circle.ttl -= 1
219
220 def renderPoints(self, painter, circles):
221 for i, circle in enumerate(circles):
222 if circle.ttl < -20:
223 # 重新初始化一个
224 circle = Circle('', self.screenWidth, self.screenHeight)
225 circles[i] = circle
226 self.drawCircle(painter, circle)
227
228 circles_len = len(circles)
229 for i in range(circles_len - 1):
230 for j in range(i + 1, circles_len):
231 deltax = circles[i].x - circles[j].x
232 deltay = circles[i].y - circles[j].y
233 dist = pow(pow(deltax, 2) + pow(deltay, 2), 0.5)
234 # if the circles are overlapping, no laser connecting them
235 if dist <= circles[i].radius + circles[j].radius:
236 continue
237 # otherwise we connect them only if the dist is < linkDist
238 if dist < self.linkDist:
239 xi = (1 if circles[i].x < circles[j].x else -
240 1) * abs(circles[i].radius * deltax / dist)
241 yi = (1 if circles[i].y < circles[j].y else -
242 1) * abs(circles[i].radius * deltay / dist)
243 xj = (-1 if circles[i].x < circles[j].x else 1) * \
244 abs(circles[j].radius * deltax / dist)
245 yj = (-1 if circles[i].y < circles[j].y else 1) * \
246 abs(circles[j].radius * deltay / dist)
247 path = QPainterPath()
248 path.moveTo(circles[i].x + xi, circles[i].y + yi)
249 path.lineTo(circles[j].x + xj, circles[j].y + yj)
250 # samecolor = circles[i].color == circles[j].color
251 c = QColor(circles[i].borderColor)
252 c.setAlphaF(min(circles[i].opacity, circles[j].opacity)
253 * ((self.linkDist - dist) / self.linkDist))
254 painter.setPen(QPen(c, (
255 lineBorder * backgroundMlt if circles[i].background else lineBorder) * (
256 (self.linkDist - dist) / self.linkDist)))
257 painter.drawPath(path)
258
259
260if __name__ == '__main__':

Callers 1

drawMethod · 0.95

Calls 3

drawCircleMethod · 0.95
setPenMethod · 0.80
CircleClass · 0.70

Tested by

no test coverage detected