arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa") mystring = String(font=arialFont, string="blurring with distance!", camera=ortho_cam, z=1.0, is_3d=False) # orthographic view mystring.set_shader(flatsh) # Fetch key presses. mykeys = Keyboard() # Display scene and rotate shape while DISPLAY.loop_running(): defocus.start_blur() # 1. drawing objects now renders to an offscreen texture #################### mysprite.draw() myshape.draw() defocus.end_blur() # 2. drawing now back to screen. The texture can now be used by defocus.blur() # 3. redraw these two objects applying a distance blur effect ############### defocus.blur(myshape, 4, 9, 5) # 4 is focal distance, >= 9 distance will get defocus.blur(mysprite, 4, 9, 5) # 5 x blurring, nearer than focus also blurs myshape.rotateIncY(1.247) myshape.rotateIncX(0.1613) mystring.draw() mystring.rotateIncZ(0.05) if time.time() > next_time: print("FPS:", tick / 2.0) tick=0
ball = Sphere(camera, light, radius, 12, 12, 0.0, "sphere", 0, 0, 0) ball.buf[0].set_draw_details(shader, [ballimg], 0.0, 0.0) maxdsz += 0.01 # max speed in z direction increases too sx, sy, sz = 0, mapheight / 3, 0 dsx, dsy, dsz = 0.3 * random.random() - 0.15, 0, -0.1 ball.position(sx, sy, sz) ball.rotateIncX(dsz / radius * 50) defocus.start_blur() ball.draw() mymap.draw() myecube.draw() defocus.end_blur() defocus.blur(ball, 4, 15, 2) defocus.blur(mymap, 4, 15, 2) defocus.blur(myecube, 4, 15, 2) monster.draw() # write up the score score0.draw() score1.draw() camera.was_moved = False #Press ESCAPE to terminate k = mykeys.read()