def draw_all_targets(targets): for target in targets: lon, lat = target glColor4f(0.2,0.2,0.2,0.2) if lat>(np.pi/2-1e-4): lat = np.pi/2-1e-4 pts = sphere.spherical_circle((lon, lat), 0.01, n=12) glBegin(GL_LINE_LOOP) draw_polar(pts) glEnd()
def draw_targets(targets, target, active=False): lon, lat = targets[target] if active: glColor4f(0.9, 0.3, 0.3, 0.8) else: glColor4f(0.8, 0.5, 0.0, 0.2) if lat>(np.pi/2-1e-4): lat = np.pi/2-1e-4 pts = sphere.spherical_circle((lon, lat), 0.01, n=32) glBegin(GL_LINE_LOOP) draw_polar(pts) glEnd() for angle in [0,np.pi/2, np.pi,-np.pi/2]: r1 = sphere.spherical_radial((lon,lat), 1, angle) pts = sphere.spherical_line((lon,lat), r1) glColor4f(0.0,0.0,0.0,0.3) glBegin(GL_LINES) draw_polar(pts) glEnd() if active: glColor4f(0.2, 0.5, 0.9, 0.8) r = 0.0 else: glColor4f(0.5, 0.5, 0.0, 0.1) # add pulsing while there is no touch event r = np.sin(time.clock()*2)*0.02 pts = sphere.spherical_circle((lon, lat), 0.2+r, n=32) glBegin(GL_LINE_LOOP) draw_polar(pts) glEnd() pts = sphere.spherical_circle((lon, lat), 0.8+r, n=32) glBegin(GL_LINE_LOOP) draw_polar(pts) glEnd()
def draw_fn(): global first glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glDisable(GL_LIGHTING) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0, size, 0, size, -1, 500) glMatrixMode(GL_MODELVIEW) glLoadIdentity() glEnable(GL_POINT_SMOOTH) glPointSize(2.0) glColor4f(1,0,1,1) glDisable(GL_TEXTURE_2D) glLineWidth(2.0) glEnable(GL_LINE_SMOOTH) glEnable(GL_BLEND) glDisable(GL_DEPTH_TEST) glClearColor(1,1,1,1) glClear(GL_COLOR_BUFFER_BIT) sphere_sim.make_grid(size) def draw_polar(pts): for x,y in pts: x,y = sphere.polar_to_display(x,y,size) glVertex2f(x,y) rad = 0.03 * np.pi phis,thetas = spiral_layout(100) for pt in zip(phis,thetas): lat, lon = pt lat -= np.pi/2 if lat>-1.4: pts = sphere.spherical_circle((lon, lat), rad) glColor4f(0.5, 0.5, 0.0, 0.5) glBegin(GL_LINE_LOOP) draw_polar(pts) glEnd()