def line(x0, y0, x, y, color=(1, 0, 0, 1), thickness=1): glColor4f(*color) glLineWidth(thickness) glBegin(GL_LINES) glVertex2f(x0, y0) glVertex2f(x, y) glEnd()
def circle(color, center, radius, width=0, npoints=24): """Draw a circle :Parameters: `color` : tuple The colour to use, as a 3- or 4-tuple of floats `center` : tuple The co-ordinates of the center of the circle `radius` : float The radius of the circle `width` : float The line width for the circle. If zero, circle is filled. Defaults to zero. `npoints` : int The number of vertices on the circumference of the circle. Defaults to 24. """ _set_gl_color(color) if width: gl.glLineWidth(width) gl.glBegin(gl.GL_LINE_LOOP) else: gl.glBegin(gl.GL_POLYGON) for i in xrange(npoints): theta = i * math.pi * 2 / npoints gl.glVertex2f(center[0] + radius * math.cos(theta), center[1] + radius * math.sin(theta)) gl.glEnd()
def nakresli_caru(x1, y1, x2, y2): gl.glBegin(gl.GL_LINES) # gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex2f(x1, y1) gl.glVertex2f(x2, y2) gl.glEnd()
def ellipse(color, corner, size, width=0, npoints=24): """Draw an axis-aligned ellipse :Parameters: `color` : tuple The colour to use, as a 3- or 4-tuple of floats `corner` : tuple The co-ordinates of the top-left corner of the ellipse's enclosing rectangle `size` : tuple A tuple of (width, height) for the ellipse `width` : float The line width for the ellipse. If zero, ellipse is filled. Defaults to zero. `npoints` : int The number of vertices on the circumference of the ellipse. Defaults to 24. """ _set_gl_color(color) center = (corner[0] + .5 * size[0], corner[1] + .5 * size[1]) if width: gl.glLineWidth(width) gl.glBegin(gl.GL_LINE_LOOP) else: gl.glBegin(gl.GL_POLYGON) for i in xrange(npoints): theta = i * math.pi * 2 / npoints gl.glVertex2f(center[0] + .5 * size[0] * math.cos(theta), center[1] + .5 * size[1] * math.sin(theta)) gl.glEnd()
def draw_circle(cx, cy, r, num_segments=None, mode=gl.GL_POLYGON, color=(1, 1, 1, 1)): if not num_segments: num_segments = get_num_circle_segments(r) theta = 2 * math.pi / float(num_segments) tangetial_factor = math.tan(theta) radial_factor = math.cos(theta) x = float(r) y = 0.0 gl.glColor4f(color[0], color[1], color[2], color[3]) gl.glBegin(mode) for i in xrange(num_segments): gl.glVertex2f(x + cx, y + cy) tx = y * -1 ty = x x += tx * tangetial_factor y += ty * tangetial_factor x *= radial_factor y *= radial_factor gl.glEnd()
def arc(color, corner, size, start_angle, stop_angle, width=1, npoints=24): """Draw an arc of an axis-aligned ellipse :Parameters: `color` : tuple The colour to use, as a 3- or 4-tuple of floats `corner` : tuple The co-ordinates of the top-left corner of the ellipse's enclosing rectangle `size` : tuple A tuple of (width, height) for the ellipse `start_angle` : float The start angle of the arc, in radians, counterclockwise from the positive x-axis `stop_angle` : float The start angle of the arc, in radians, counterclockwise from the positive x-axis `width` : float The line width for the ellipse. Defaults to 1.0 `npoints` : int The number of vertices on the circumference of the ellipse. Defaults to 24. """ _set_gl_color(color) center = (corner[0] + .5 * size[0], corner[1] + .5 * size[1]) gl.glLineWidth(width) gl.glBegin(gl.GL_LINE_STRIP) for i in range(npoints + 1): theta = start_angle + (float(i * (stop_angle - start_angle)) / npoints) gl.glVertex2f(center[0] + .5 * size[0] * math.cos(theta), center[1] + .5 * size[1] * math.sin(theta)) gl.glEnd()
def show_risk(self): # print('%s' % self.infos) # print("%s" % hasattr(self, 'reward_strategy')) if self.infos[0] != None and self.infos[0]['on_rect'] and hasattr(self, 'reward_strategy'): # win = self.env.viewers[0].window # win.switch_to() # win.dispatch_events() rect = self.infos[0]['last_rect'] rectx = sorted(list(set(map(lambda item: item[0], rect)))) # unique x recty = sorted(list(set(map(lambda item: item[1], rect)))) # unique y # gl.glViewport(0, 0, 96, 96) gl.glPointSize(3.3) gl.glBegin(gl.GL_POINTS) oc = [0.5, 0.5, 0.5] gl.glColor4f(*oc, 1.0) x = rectx[0] while x < rectx[1]: y = recty[0] while y < recty[1]: r = self.reward_strategy.risk(x, y) gl.glColor4f(r*oc[0], r*oc[1], r*oc[2], 1.0) print("%s = %s" % ((x, y), r)) gl.glVertex2f(x, y, 0) y += 1.0 x += 1.0 gl.glEnd()
def draw_block(block): transformed = [world_to_screen(block.GetWorldPoint(p)) for p in POINTS] gl.glColor3f(1.0, 0.1, 0) gl.glBegin(gl.GL_LINE_LOOP) for p in transformed: gl.glVertex2f(*p) gl.glEnd()
def _draw_baseline(self): if self.draw_baseline: gl.glColor3f(0, 0, 0) gl.glBegin(gl.GL_LINES) gl.glVertex2f(0, 200) gl.glVertex2f(self.window.width, 200) gl.glEnd()
def draw(self, colour=(0., 0., 1.)): s = self.size # just a shorthand gl.glColor3f(*colour) gl.glBegin(gl.GL_LINE_LOOP) for vertex in self.verticies: gl.glVertex2f(*vertex) gl.glEnd()
def draw_points(self): self.points_lock.acquire() try: from pyglet.gl import glCallList, glBegin, GL_LINE_STRIP, glColor4f, glVertex2f, glEnd # line from previous iterate to next iterate of function glBegin(GL_LINE_STRIP) glColor4f(1, 1, 1, 0.3) state_index = self.state_indices[0] for i in [1, 2]: state_previous = self.point.state[state_index] self.point.state = self.system.iterate(self.point.state, self.point.parameters) glVertex2f(state_previous, state_previous) glVertex2f(state_previous, self.point.state[state_index]) glEnd() # call display lists, doesn't work in init_points() if self.server.iteration <= 1: glCallList(self.iterate_list) glCallList(self.reflection_list) except Exception, detail: print "draw_points()", type(detail), detail
def graph(x, y, val): x = int(x) y = int(y) if val == 1: origin = [x, y] # middle left, middle right, top middle, top left, top right, top top # tt # tl tr # ml tm mr # or ml = [x - side_length, y + int(side_length / 2)] mr = [x + side_length, y + int(side_length / 2)] tm = [x, y + int(side_length / 2)] tl = [ml[0], ml[1] + int(side_length / 2)] tr = [mr[0], mr[1] + int(side_length / 2)] tt = [x, y + int(1.5 * side_length)] gl.glBegin(gl.GL_POLYGON) gl.glColor3f(0, 0, 0) for point in [origin, ml, tl, tt, tr, mr, origin]: gl.glVertex2f(*point) gl.glEnd() line(*origin, *ml) line(*origin, *mr) line(*mr, *tr) line(*ml, *tl) line(*origin, *tm) line(*tl, *tm) line(*tr, *tm) line(*tl, *tt) line(*tr, *tt) else: pass
def lines(self, *points): glColor4f(*self._stroke_color) glLineWidth(self._line_width) glBegin(GL_LINE_STRIP) for point in points: glVertex2f(point.x, point.y) glEnd()
def draw_points(self): self.points_lock.acquire() try: from pyglet.gl import glBegin, glEnd, GL_POINTS, glColor4f, glVertex2f glBegin(GL_POINTS) for i in xrange(0, len(self.points)): p = self.points[i] parameter_index = self.parameter_indices[0] state_index = self.state_indices[0] glColor4f(1, 1, 1, p.age / (self.age_max*2.0)) glVertex2f(p.parameters[parameter_index], p.state[state_index]) p.state = self.system.iterate(p.state, p.parameters) p.age += 1 #if p.age >= self.age_max: # self.points[i] = OrbitPoint(tool=self, varying_parameter=p.parameters[parameter_index]) glEnd() except Exception, detail: print 'draw_points()', type(detail), detail
def render_additional_points(self, pts): if pts == None: return gl.glPointSize(5) gl.glBegin(gl.GL_POINTS) for (x, y) in pts: gl.glColor4f(0, 0, 1.0, 1.0) gl.glVertex2f(x, y, 0) gl.glEnd()
def display_pointer(angle, color, radius): x_value = math.cos(angle) y_value = math.sin(angle) glBegin(GL_LINES) glColor3ub(*color) glVertex2f(0.0, 0.0) glVertex2f(x_value * radius, y_value * radius) glEnd()
def draw(self): r = self.size.x gl.glColor3f(1.0, .7, 0.0) with shiftView(self.body.position): gl.glBegin(gl.GL_LINE_LOOP) for angle in xrange(0, 360, 360/12): gl.glVertex2f(*self.size.rotated_degrees(angle)) gl.glEnd()
def draw_line(self): """Function for drawing a line""" gl.glColor4f(*self.color) gl.glLineWidth(self.thickness) gl.glBegin(gl.GL_LINES) gl.glVertex2f(self.coordx[0], self.coordy[0]) gl.glVertex2f(self.coordx[1], self.coordy[1]) gl.glEnd()
def draw_circle_sector(center, angle, radius, n, color, triangles_to_draw): gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glColor3f(*color) gl.glVertex2f(*center) for i in range(triangles_to_draw + 1): gl.glVertex2f(center[0] + np.cos(2. * np.pi / n * i + angle) * radius, center[1] + np.sin(2. * np.pi / n * i + angle) * radius) gl.glEnd()
def draw_line(x1, y1, x2, y2, width=2): glLineStipple(1, 0xFF) glEnable(GL_LINE_STIPPLE) glLineWidth(width) glBegin(GL_LINES) glVertex2f(x1, y1) glVertex2f(x2, y2) glEnd()
def draw_circle(position, size=20, num_of_segments=30): glBegin(GL_LINE_LOOP) for i in range(num_of_segments): theta = 2.0 * 3.1415926 * i / num_of_segments cx = size * math.cos(theta) cy = size * math.sin(theta) glVertex2f(position.x + cx, position.y + cy) glEnd()
def draw_cartpole(cartpole, screen_width): world_width = cartpole.x_threshold * 2 scale = screen_width / world_width carty = 100 # TOP OF CART polewidth = 10.0 polelen = scale * 1.0 * (cartpole.length / 0.5) cartwidth = 50.0 cartheight = 30.0 # Draw track glColor4f(0, 0, 0, 1.0) glLineWidth(1.0) glBegin(gl.GL_LINES) glVertex2f(0, carty) glVertex2f(screen_width, carty) glEnd() # Draw Cart l, r, t, b = -cartwidth / 2, cartwidth / 2, cartheight / 2, -cartheight / 2 cartx = cartpole.x * scale + screen_width / 2.0 # MIDDLE OF CART glColor4f(0., 0., 0., 1.0) glPushMatrix() # Push Translation glTranslatef(cartx, carty, 0) glBegin(gl.GL_QUADS) glVertex3f(l, b, 0) glVertex3f(l, t, 0) glVertex3f(r, t, 0) glVertex3f(r, b, 0) glEnd() # Draw Pole l, r, t, b = (-polewidth / 2, polewidth / 2, polelen - polewidth / 2, -polewidth / 2) glColor4f(.8, .6, .4, 1.0) glPushMatrix() # Push Rotation glRotatef(RAD2DEG * -cartpole.theta, 0, 0, 1.0) glBegin(gl.GL_QUADS) glVertex3f(l, b, 0) glVertex3f(l, t, 0) glVertex3f(r, t, 0) glVertex3f(r, b, 0) glEnd() glPopMatrix() # Pop Rotation # Draw Axle radius = polewidth / 2 glColor4f(0.5, 0.5, 0.8, 1.0) glBegin(gl.GL_POLYGON) for i in range(12): ang = 2 * math.pi * i / 12 x = math.cos(ang) * radius y = math.sin(ang) * radius glVertex3f(x, y, 0) glEnd() glPopMatrix() # Pop Translation
def draw_ball(center, angle, radius, n, color, line_color): draw_circle_sector(center, angle, radius, n, color, n) gl.glBegin(gl.GL_LINES) gl.glColor3f(*line_color) gl.glVertex2f(center[0] - np.cos(angle) * radius, center[1] - np.sin(angle) * radius) gl.glVertex2f(center[0] - np.cos(angle + np.pi) * radius, center[1] - np.sin(angle + np.pi) * radius) gl.glEnd()
def line_loop(self, *points): if len(points) <= 2: raise ValueError() glColor4f(*self._stroke_color) glLineWidth(self._line_width) glBegin(GL_LINE_LOOP) for point in points: glVertex2f(point.x, point.y) glEnd()
def draw(self): gl.glColor3f(1, 1, 1) gl.glBegin(gl.GL_LINES) gl.glVertex2f(0, 50) gl.glVertex2f(self.window.width, 50) gl.glEnd() for label in self.labels: label.draw()
def draw_line(a, b, color): gl.glPushMatrix() gl.glColor3f(color[0], color[1], color[2]) gl.glLineWidth(2) gl.glBegin(gl.GL_LINES) gl.glVertex2f(a[0], a[1]) gl.glVertex2f(b[0], b[1]) gl.glEnd() gl.glPopMatrix()
def point(self, *args): if len(args) == 2: x, y = args[0], args[1] if len(args) == 1 and type(args[0]) == Point: x, y = args.x, args.y glColor4f(*self._stroke_color) glBegin(GL_POINTS) glVertex2f(x, y) glEnd()
def draw_circle(center, radius): sides = 64 glBegin(GL_POLYGON) for i in range(100): cosine = radius * cos(i * 2 * pi / sides) + center[0] sine = radius * sin(i * 2 * pi / sides) + center[1] glVertex2f(cosine, sine) glEnd()
def draw_fan(center, vertices, color): gl.glPushMatrix() gl.glColor4f(*color) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex2f(center[0], center[1]) for vertex in vertices: gl.glVertex2f(vertex[0], vertex[1]) gl.glEnd() gl.glPopMatrix()
def draw_point(pos, color=(1, 0, 0, 1), size=5): gl.glColor4f(*color) gl.glPointSize(size) gl.glBegin(gl.GL_POINTS) gl.glVertex2f(*pos) gl.glEnd() # -- reset color gl.glColor4f(1, 1, 1, 1)
def draw_rectangle(self, vertexes): '''Draws rectangle around game field. ''' gl.glLineWidth(2) gl.glClearColor(0, 0, 0, 1) gl.glColor3f(1, 1, 1) gl.glBegin(gl.GL_LINE_LOOP) for point in vertexes: gl.glVertex2f(point[0], point[1]) gl.glEnd()
def line(x, y, size, angle, color=(1, 0, 0, 1), thickness=1): x1, y1 = x, y x2, y2 = x1 + cos(angle) * size, y1 + sin(angle) * size glColor4f(*color) glLineWidth(thickness) glBegin(GL_LINES) glVertex2f(x1, y1) glVertex2f(x2, y2) glEnd()
def draw(self): #print self.body.postion s = self.size # just a shorthand gl.glColor4f(*(self.colour + (self.opacity,))) with shiftView(Vec2d(self.body.position)): gl.glRotatef(degrees(self.body.angle), 0.1,0.2,1.0) gl.glBegin(gl.GL_POLYGON) for vertex in self.verticies: gl.glVertex2f(*vertex) gl.glEnd()
def draw_bone(self, bone): p1 = bone.get_start() p2 = bone.get_end() gl.glColor4ub(*self.color) gl.glLineWidth(5) gl.glBegin(gl.GL_LINES) gl.glVertex2f(*p1) gl.glVertex2f(*p2) gl.glEnd()
def render(self, triangle, has_food): color = self.food_color if has_food else self.normal_color glBegin(GL_TRIANGLES) glColor3f(color[0], color[1], color[2]) for v in triangle.vertices: glVertex2f(*v) glEnd()
def draw(self): if not self.visible: return gl.glLineWidth(2) # deprecated gl.glColor3ub(*self.color3) gl.glBegin(gl.GL_LINE_STRIP) for v in self.vertexes: gl.glVertex2f(*v) gl.glVertex2f(*self.vertexes[0]) gl.glEnd()
def draw_line(start, end, color=(1, 1, 0, 1), width=2): gl.glColor4f(*color) gl.glLineWidth(width) gl.glBegin(gl.GL_LINES) gl.glVertex2f(*start) gl.glVertex2f(*end) gl.glEnd() # -- reset color gl.glColor4f(1, 1, 1, 1)
def draw_path(points, color=(1, 0, 1, 1), width=5): gl.glColor4f(*color) gl.glLineWidth(width) gl.glBegin(gl.GL_LINE_STRIP) for point in points: gl.glVertex2f(*point) gl.glEnd() # -- reset color gl.glColor4f(1, 1, 1, 1)
def blit(self, x, y, w, h, z=0, s=(0,1), **kwargs): ''' Draw texture to active framebuffer. ''' gl.glEnable (gl.GL_TEXTURE_2D) gl.glDisable (gl.GL_TEXTURE_1D) gl.glBindTexture(self.target, self._id) gl.glBegin(gl.GL_QUADS) gl.glTexCoord2f(s[0], 1), gl.glVertex2f(x, y) gl.glTexCoord2f(s[0], 0), gl.glVertex2f(x, y+h) gl.glTexCoord2f(s[1], 0), gl.glVertex2f(x+w, y+h) gl.glTexCoord2f(s[1], 1), gl.glVertex2f(x+w, y) gl.glEnd()
def circle(x, y, radius): iterations = int(tau * radius) * 2 s = sin(tau / iterations) c = cos(tau / iterations) gl.glBegin(gl.GL_TRIANGLE_FAN) gl.glVertex2f(x, y) dx, dy = radius, 0 for i in range(iterations + 1): gl.glVertex2f(x + dx, y + dy) dx, dy = (dx * c - dy * s), (dy * c + dx * s) gl.glEnd()
def on_draw(): global vertices gl.glClear(gl.GL_COLOR_BUFFER_BIT) gl.glColor3f(0, 0, 0) gl.glBegin(gl.GL_TRIANGLES) for vertex in vertices: gl.glVertex2f(*vertex) gl.glEnd()
def render_change_vectors(self): glBegin(GL_LINES) color = [0.0, 0.0, 0.0] for i, (factor, vec) in enumerate(self.change_vectors): color[i % 3] = 1.0 glColor3f(*color) glVertex2f(0.0, 0.0) glVertex2f(*[i * factor * _CHANGE_VECTOR_LENGTH for i in vec]) color[i % 3] = 0.0 glEnd()
def render_view(self): glColor3f(0.6, 0.1, 0.1) glBegin(GL_LINE_LOOP) step = 10 # render a circle for the boid's view for i in range(-_BOID_VIEW_ANGLE, _BOID_VIEW_ANGLE + step, step): glVertex2f(_BOID_RANGE * math.sin(math.radians(i)), (_BOID_RANGE * math.cos(math.radians(i)))) glVertex2f(0.0, 0.0) glEnd()
def on_draw(): gl.glClear(gl.GL_COLOR_BUFFER_BIT) gl.glMatrixMode(gl.GL_MODELVIEW) gl.glLoadIdentity() transformed = [world_to_screen(block.GetWorldPoint(p)) for p in POINTS] gl.glColor3f(1.0, 0.1, 0) gl.glBegin(gl.GL_QUADS) for p in transformed: gl.glVertex2f(*p) gl.glEnd()
def circle(x, y, radius): iterations = 20 s = math.sin(2*math.pi / iterations) c = math.cos(2*math.pi / iterations) dx, dy = radius, 0 gl.glBegin(gl.GL_LINE_STRIP) for i in range(iterations+1): gl.glVertex2f(x+dx, y+dy) dx, dy = (dx*c - dy*s), (dy*c + dx*s) gl.glEnd()
def draw_obj(body, tex): gl.glEnable(gl.GL_TEXTURE_2D) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP) gl.glBindTexture(gl.GL_TEXTURE_2D, tex.id) transformed = [world_to_screen(body.GetWorldPoint(p)) for p in POINTS] gl.glBegin(gl.GL_QUADS) for p, tc in zip(transformed, TEX_COORDS): gl.glTexCoord2f(*tc) gl.glVertex2f(*p) gl.glEnd()
def rectangle(x1, y1, x2, y2): gl.glBegin(gl.GL_TRIANGLE_STRIP) gl.glVertex2f(x1, y1) gl.glVertex2f(x1, y2) gl.glVertex2f(x2, y1) gl.glVertex2f(x2, y2) gl.glEnd()
def core_draw(self): super(PointDisplayCanvas, self).core_draw() points, point_colors, linesegs, lineseg_colors = self.extra_points_linesegs gl.glColor4f(0.0, 1.0, 0.0, 1.0) # green point if points is not None: if point_colors is None: point_colors = [(0, 1, 0, 1)] * len(points) gl.glBegin(gl.GL_POINTS) for color_4tuple, pt in zip(point_colors, points): gl.glColor4f(*color_4tuple) gl.glVertex2f(pt[0], pt[1]) gl.glEnd() if linesegs is not None: if lineseg_colors is None: lineseg_colors = [(0, 1, 0, 1)] * len(linesegs) gl.glBegin(gl.GL_LINES) for color_4tuple, (x0, y0, x1, y1) in zip(lineseg_colors, linesegs): gl.glColor4f(*color_4tuple) gl.glVertex2f(x0, y0) gl.glVertex2f(x1, y1) gl.glEnd() if self.red_points is not None: gl.glColor4f(1.0, 0.0, 0.0, 1.0) gl.glBegin(gl.GL_POINTS) for pt in self.red_points: gl.glVertex2f(pt[0], pt[1]) gl.glEnd() gl.glColor4f(1.0, 1.0, 1.0, 1.0) # restore white color
def draw_segment(shape, color): position = shape.body.position a = shape.a b = shape.b radius = shape.radius gl.glPushMatrix() gl.glColor3f(color[0], color[1], color[2]) gl.glTranslatef(position[0], position[1], 0) gl.glLineWidth(radius) gl.glBegin(gl.GL_LINES) gl.glVertex2f(a[0], a[1]) gl.glVertex2f(b[0], b[1]) gl.glEnd() gl.glPopMatrix()
def draw(self): from miru.context import context gl.glEnable(gl.GL_LINE_STIPPLE) gl.glLineStipple(1, 0x51315) gl.glColor4f(*self.color) for c in self.metaCamera.cameras: vp = c.projection x = vp.x == 0 and 1 or vp.x width = vp.x == 0 and vp.width - 1 or vp.width width = (vp.x + vp.width) >= context.window.width and width - 1 or width y = vp.y == 0 and 1 or vp.y height = vp.y == 0 and vp.height - 1 or vp.height height = (vp.y + vp.height) >= context.window.height and height - 1 or height gl.glBegin(gl.GL_LINE_LOOP) gl.glVertex2f(x, y) gl.glVertex2f(x, y + height) gl.glVertex2f(x + width, y + height) gl.glVertex2f(x + width, y) gl.glEnd() gl.glDisable(gl.GL_LINE_LOOP) gl.glColor4f(1,1,1,1)
def circle(cx, cy, r, color): segments = int(2 * math.pi * r) cos = math.cos(2 * math.pi / segments) sin = math.sin(2 * math.pi / segments) x, y = r, 0 glBegin(GL_TRIANGLE_FAN) glColor3f(*color) for counter in range(segments): glVertex2f(x + cx, y + cy) x, y = cos * x - sin * y, sin * x + cos * y glEnd()
def draw_gl_circle(circle): radius = circle.width / 2 iterations = int(2 * radius * pi) s = sin(2 * pi / iterations) c = cos(2 * pi / iterations) dx, dy = radius, 0 glBegin(GL_TRIANGLE_FAN) glVertex2f(circle.x, circle.y) for i in range(iterations + 1): glVertex2f(circle.x + dx, circle.y + dy) dx, dy = (dx * c - dy * s), (dy * c + dx * s) glEnd()
def draw_rectangle(x1, y1, x2, y2, r, g, b): gl.glColor4ub(r, g, b, 255) gl.glBegin(gl.GL_QUADS) gl.glVertex2f(x1, y1) gl.glVertex2f(x2, y1) gl.glVertex2f(x2, y2) gl.glVertex2f(x1, y2) gl.glEnd()