def _appendRegexMarkup(s, result): while s: m = extlinkre.search(s) if m: frag = s[:m.start()] splice = ExternalLink(m.group(1), m.group(1)) s = m.group(3) + s[m.end():] else: frag = s splice = None s = '' frag = cgi.escape(frag) frag = boldre.sub(r'<b>\1</b>', frag) frag = italre.sub(r'<i>\1</i>', frag) frag = underre.sub(r'<u>\1</u>', frag) while 1: m = intlinkre.search(frag) if m: result.append(HtmlFragment(frag[:m.start()])) result.append(RenderUtils.InternalLink(m.group())) frag = frag[m.end():] else: result.append(HtmlFragment(frag)) break if splice: result.append(splice)
def __init__(self, coords=[0, 0, 0]): #sets object variables, pretty self-explanatory self.x = coords[0] self.y = coords[1] self.z = coords[2] self.color = RenderUtils.randomColor() #FIXED ERROR: sometimes this function is called #before the first spheres = [] line is called, #therefore in this case, you must create a global #spheres variable to prevent error global spheres #adds the created sphere into the array spheres.append(self)
def render_tex_mesh_func(self, fv_indices, tri_uvs, tri_normals, tex_img, vps, camera_dict): proj_pixels, z_vals, v_status = self.project_mesh_vps(vps, camera_dict) tri_proj_pixels = (proj_pixels[fv_indices]).reshape(-1, 6) tri_z_vals = z_vals[fv_indices] #[n_f, 3] tri_status = (v_status[fv_indices]).all(axis=1) #[n_f] cam_w = camera_dict["CameraReso"][0] cam_h = camera_dict["CameraReso"][1] ex_mat = camera_dict["ExterMat"] depth_img = np.ones((cam_h, cam_w), np.float32) * 100.0 rgb_img = np.zeros((cam_h, cam_w, 3), np.float32) mask_img = np.zeros((cam_h, cam_w), np.int32) w_light_dx = self.light_dire[0] w_light_dy = self.light_dire[1] w_light_dz = self.light_dire[2] c_light_dx = ex_mat[0, 0] * w_light_dx + ex_mat[ 0, 1] * w_light_dy + ex_mat[0, 2] * w_light_dz c_light_dy = ex_mat[1, 0] * w_light_dx + ex_mat[ 1, 1] * w_light_dy + ex_mat[1, 2] * w_light_dz c_light_dz = ex_mat[2, 0] * w_light_dx + ex_mat[ 2, 1] * w_light_dy + ex_mat[2, 2] * w_light_dz ambient_strength = self.ambient_strength light_strength = self.light_strength RenderUtils.render_tex_mesh(tri_normals, tri_uvs, tri_proj_pixels, tri_z_vals, tri_status, tex_img, depth_img, rgb_img, mask_img, c_light_dx, c_light_dy, c_light_dz, ambient_strength, light_strength) depth_img[mask_img < 0.5] = 0 return rgb_img, depth_img, mask_img
def SublanguageHandler(args, doc, renderer): command = Config.dot_command + ' -Tpng' (child_stdin, child_stdout) = os.popen2(command) child_stdin.write(doc.reconstruct_child_text().as_string()) child_stdin.close() pngdata = child_stdout.read() child_stdout.close() if not renderer.page.mediacache().has_key('__dot_counter'): renderer.page.mediacache()['__dot_counter'] = 0 index = renderer.page.mediacache()['__dot_counter'] name = 'dot' + str(index) renderer.page.mediacache()['__dot_counter'] = index + 1 cachepath = 'dot/' + name + '.png' renderer.add( RenderUtils.media_cache(renderer, cachepath, '[Dot figure ' + name + ']', 'pyle_mediacache_image', 'image/png', pngdata))
def SublanguageHandler(args, doc, renderer): args = args.split(' ') name = args[0] input = '.PS' if len(args) > 1: input = input + ' ' + args[1] input = input + '\ncopy "./sublanguages/sequence.pic";\n' \ + doc.reconstruct_child_text().as_string() \ + '\n\n.PE\n' #input = runpipe('/usr/bin/pic2plot -T fig', input) #output = runpipe('/usr/bin/fig2dev -L png', input) output = runpipe('./sublanguages/sequence-helper.sh', input) cachepath = 'sequence/' + name + '.png' renderer.add( RenderUtils.media_cache(renderer, cachepath, '[Sequence diagram ' + name + ']', 'pyle_mediacache_image', 'image/png', output))
def SublanguageHandler(args, doc, renderer): args = args.split(' ') name = args[0] input = '.PS' if len(args) > 1: input = input + ' ' + args[1] input = input + '\ncopy "./sublanguages/sequence.pic";\n' \ + doc.reconstruct_child_text().as_string() \ + '\n\n.PE\n' #input = runpipe('/usr/bin/pic2plot -T fig', input) #output = runpipe('/usr/bin/fig2dev -L png', input) output = runpipe('./sublanguages/sequence-helper.sh', input) cachepath = 'sequence/' + name + '.png' renderer.add(RenderUtils.media_cache(renderer, cachepath, '[Sequence diagram ' + name + ']', 'pyle_mediacache_image', 'image/png', output))
def SublanguageHandler(args, doc, renderer): command = Config.dot_command + ' -Tpng' (child_stdin, child_stdout) = os.popen2(command) child_stdin.write(doc.reconstruct_child_text().as_string()) child_stdin.close() pngdata = child_stdout.read() child_stdout.close() if not renderer.page.mediacache().has_key('__dot_counter'): renderer.page.mediacache()['__dot_counter'] = 0 index = renderer.page.mediacache()['__dot_counter'] name = 'dot' + str(index) renderer.page.mediacache()['__dot_counter'] = index + 1 cachepath = 'dot/' + name + '.png' renderer.add(RenderUtils.media_cache(renderer, cachepath, '[Dot figure ' + name + ']', 'pyle_mediacache_image', 'image/png', pngdata))
#FIXED BUG: if statement is used to fix the error in the rare case the key_name is not already in keyPressed if (key_name in keyPressed): #removes the key name to keyPressed keyPressed.remove(key_name) #stops playing rocket sound SOUND_ROCKET.stop() #Here's where all the code for the INTRO screen lies if (player.screenType == ScreenType.INTRO): #initialize changeTitleColor and Clock changeTitleColor = False CLOCK = pygame.time.Clock() #timer to change title color if (pygame.time.get_ticks() % 2000 == 0): changeTitleColor = True #draw intro screen RenderUtils.drawIntro(clicking, changeTitleColor) #FIXED BUG: resets keyPressed because sometimes pygame never calls the keyUp event, #leading the program to think the key is pressed when it isn't. keyPressed = [] #FIXED BUG: speed values didn't reset for new game yawSpeed = 0 pitchSpeed = 0 rollSpeed = 0 speed = 0 #Here's where all the code for the GAME screen lies elif (player.screenType == ScreenType.GAME): player.z += speed #Matrix Transformations(3D rotations) transformAll(yawSpeed, "Y") transformAll(pitchSpeed, "X") transformAll(rollSpeed, "Z")
def drawSphere(self): RenderUtils.drawPoint(self.get2D(), self.getRealRadius(), self.color)