def paintGL(self, sun_x, sun_y, sun_z, moon_x, moon_y, moon_z):
# Draw the sun
self.fbo.bind()
self.draw_sun(sun_x, sun_y, sun_z)
glFlush()
self.fbo.release()
image = self.fbo.toImage()
# Produce blurred image of sun
npimage = qimage_to_numpy(image)
h, w, b = npimage.shape
blur = cv2.GaussianBlur(npimage, (75, 75), 0, 0)
cv2.convertScaleAbs(blur, blur, 2, 1)
# Combine the blurred with the sun
combo = cv2.addWeighted(blur, 0.5, npimage, 0.5, -1)
h, w, b = combo.shape
qimage = QtGui.QImage(combo.data,w,h,QtGui.QImage.Format_ARGB32).rgbSwapped()
self.fbo.bind()
device = QtGui.QOpenGLPaintDevice(RES_X, RES_Y)
painter = QtGui.QPainter()
painter.begin(device)
rect = QtCore.QRect(0, 0, RES_X, RES_Y)
# Draw the blurred sun/sun combo image on the screen
painter.drawImage(rect, qimage, rect)
painter.end()
self.fbo.release()
# Draw the moon
self.fbo.bind()
self.draw_moon(moon_x, moon_y, moon_z)
glFlush()
self.fbo.release()
评论列表
文章目录