コード例 #1
0
 def draw_lasers(self):
     batch = Batch()
     inner_colors = (0, 200, 255, 0, 200, 255)
     radius = 3 * SpaceWindow.BULLET_RADIUS_PERCENT * self.width
     for bullet in self.model.bullets:
         # self.draw_illumination(self.to_screen_x(bullet[0]), self.to_screen_y(bullet[1]), radius, inner_colors[:3])
         batch.add(2, GL_LINES, None,
                   ('v2f', [self.to_screen_x(bullet[0]),
                            self.to_screen_y(bullet[1]),
                            self.to_screen_x(bullet[0]),
                            self.to_screen_y(bullet[1] + int(self.BULLET_HEIGHT_PERCENT * self.main_height))]),
                   ('c3B', inner_colors))
     radius = SpaceWindow.BULLET_RADIUS_PERCENT * self.width
     purple = [255, 0, 255]
     for x, y in self.model.alien_bullets:
         self.draw_illumination(self.to_screen_x(x), self.to_screen_y(y), 6 * radius, purple)
         circ_pts = [self.to_screen_x(x), self.to_screen_y(y) + radius]
         for theta in np.linspace(0, 2 * math.pi, 8):
             error = random.randint(-1 * radius // 4, radius // 4)
             circ_pts.extend([circ_pts[0] + (radius + error) * math.sin(theta),
                              circ_pts[1] + (radius + error) * math.cos(theta)])
         num_of_vert = (len(circ_pts) // 2)
         colors = [255, 255, 255]
         colors.extend((num_of_vert - 1) * purple)
         graphics.draw(num_of_vert, GL_TRIANGLE_FAN,
                       ('v2f', circ_pts),
                       ('c3B', colors))
     batch.draw()
コード例 #2
0
ファイル: gui.py プロジェクト: Bogdanp/ymage
 def draw(self):
     if self.text:
         width, height = len(self.text) * 7 + 20, 30
         graphics.draw(4, gl.GL_QUADS,
                       ("v2f", (0, 0, 0, height, width, height, width, 0)),
                       ("c4f", (1, 1, 1, 1) * 4))
     super(Printer, self).draw()
コード例 #3
0
ファイル: ship.py プロジェクト: frlnx/melee
 def _draw_local(self):
     draw(4, GL_LINES,
          ('v3f',
           list([
               a + b for a, b in zip(self.cross_base,
                                     cycle(self.model.center_of_mass))
           ])))
コード例 #4
0
ファイル: graphx.py プロジェクト: felipeCeler/reactbar
def drawRectangle(
        pos=(0, 0),
        size=(1.0, 1.0),
):
    data = (pos[0], pos[1], pos[0] + size[0], pos[1], pos[0] + size[0],
            pos[1] + size[1], pos[0], pos[1] + size[1])
    draw(4, GL_QUADS, ('v2f', data))
コード例 #5
0
ファイル: simulator.py プロジェクト: sjunges/VerifAI
    def on_draw(self):
        self.window.clear()
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        self.camera()
        gl.glEnable(self.background.target)
        gl.glEnable(gl.GL_BLEND)
        gl.glBindTexture(self.background.target, self.background.id)
        W = 10000.
        graphics.draw(4, gl.GL_QUADS, ('v2f', (-W, -W, W, -W, W, W, -W, W)),
                      ('t2f',
                       (0., 0., W * 5., 0., W * 5., W * 5., 0., W * 5.)))
        gl.glDisable(self.background.target)
        for lane in self.world.lanes:
            self.draw_lane_surface(lane)
            self.draw_lane_lines(lane)
        for obj in self.world.objects:
            self.draw_object(obj)
        for car in self.world.cars:
            self.draw_car(car.trajectory[-1], car.color)
        gl.glPopMatrix()

        self.label.text = self.task_name
        self.label.draw()
        self.iter += 1
        if self.iter % 10 == 0:
            print('Iterations: ', self.iter)
        if self.iter == self.max_iters:
            self.event_loop.exit()
コード例 #6
0
    def _draw_lane(self, lane: StraightLane):
        """Draws a `StraightLane`."""
        # first, draw the asphalt
        gl.glColor3f(0.4, 0.4, 0.4)  # set color to gray
        graphics.draw(
            4,
            gl.GL_QUAD_STRIP,
            (
                "v2f",
                np.hstack([
                    lane.p - 0.5 * lane.w * lane.n,
                    lane.p + 0.5 * lane.w * lane.n,
                    lane.q - 0.5 * lane.w * lane.n,
                    lane.q + 0.5 * lane.w * lane.n,
                ]),
            ),
        )
        # next, draw the white lines between lanes

        gl.glColor3f(1.0, 1.0, 1.0)  # set color to white
        graphics.draw(
            4,
            gl.GL_LINES,
            (
                "v2f",
                np.hstack([
                    lane.p - 0.5 * lane.w * lane.n,
                    lane.q - 0.5 * lane.w * lane.n,
                    lane.p + 0.5 * lane.w * lane.n,
                    lane.q + 0.5 * lane.w * lane.n,
                ]),
            ),
        )
コード例 #7
0
 def draw_lane_surface(self, lane):
     gl.glColor3f(0.4, 0.4, 0.4)
     W = 1000
     graphics.draw(4, gl.GL_QUAD_STRIP, ('v2f',
         np.hstack([lane.p-lane.m*W-0.5*lane.w*lane.n, lane.p-lane.m*W+0.5*lane.w*lane.n,
                    lane.q+lane.m*W-0.5*lane.w*lane.n, lane.q+lane.m*W+0.5*lane.w*lane.n])
     ))
コード例 #8
0
 def draw_lane_lines(self, lane):
     gl.glColor3f(1., 1., 1.)
     W = 1000
     graphics.draw(4, gl.GL_LINES, ('v2f',
         np.hstack([lane.p-lane.m*W-0.5*lane.w*lane.n, lane.p+lane.m*W-0.5*lane.w*lane.n,
                    lane.p-lane.m*W+0.5*lane.w*lane.n, lane.p+lane.m*W+0.5*lane.w*lane.n])
     ))
コード例 #9
0
ファイル: renderer.py プロジェクト: robin-weiland/pMC
 def drawFocusedBlock(self):
     block = self.game.world.hitTest(self.game.player.position, self.game.player.sightVector())[0]
     if block and self.game.world[block] != self.game.textures.edge:
         x, y, z, = block
         glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
         draw(24, GL_QUADS, ('v3f/static', cube_vertices(x, y, z, 0.5),), ('c3B/static', (0, 0, 0,) * 24,))
         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
コード例 #10
0
 def draw_lane_surface(self, lane):
     gl.glColor3f(0.4, 0.4, 0.4)
     W = 1000
     graphics.draw(4, gl.GL_QUAD_STRIP, ('v2f',
         np.hstack([lane.p-lane.m*W-0.5*lane.w*lane.n, lane.p-lane.m*W+0.5*lane.w*lane.n,
                    lane.q+lane.m*W-0.5*lane.w*lane.n, lane.q+lane.m*W+0.5*lane.w*lane.n])
     ))
コード例 #11
0
 def on_draw(self):
     self.window.clear()
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glPushMatrix()
     gl.glLoadIdentity()
     self.camera()
     gl.glEnable(self.grass.target)
     gl.glEnable(gl.GL_BLEND)
     gl.glBindTexture(self.grass.target, self.grass.id)
     W = 10000.
     graphics.draw(4, gl.GL_QUADS,
         ('v2f', (-W, -W, W, -W, W, W, -W, W)),
         ('t2f', (0., 0., W*5., 0., W*5., W*5., 0., W*5.))
     )
     gl.glDisable(self.grass.target)
     for lane in self.lanes:
         self.draw_lane_surface(lane)
     for lane in self.lanes:
         self.draw_lane_lines(lane)
     for obj in self.objects:
         self.draw_object(obj)
     for car in self.cars:
         if car!=self.main_car and car not in self.visible_cars:
             self.draw_car(self.anim_x[car], car.color)
     if self.heat is not None:
         self.draw_heatmap()
     for car in self.cars:
         if car==self.main_car or car in self.visible_cars:
             self.draw_car(self.anim_x[car], car.color)
     gl.glPopMatrix()
     if isinstance(self.main_car, Car):
         self.label.text = 'Speed: %.2f'%self.anim_x[self.main_car][3]
         self.label.draw()
     if self.output is not None:
         pyglet.image.get_buffer_manager().get_color_buffer().save(self.output.format(self.frame))
コード例 #12
0
 def draw_lane_lines(self, lane):
     gl.glColor3f(1., 1., 1.)
     W = 1000
     graphics.draw(4, gl.GL_LINES, ('v2f',
         np.hstack([lane.p-lane.m*W-0.5*lane.w*lane.n, lane.p+lane.m*W-0.5*lane.w*lane.n,
                    lane.p-lane.m*W+0.5*lane.w*lane.n, lane.p+lane.m*W+0.5*lane.w*lane.n])
     ))
コード例 #13
0
def draw_reg_polygon(x, y, r, n, color=(255, 255, 255, 0)):
    vertices = []
    th = 0
    for _ in range(n):
        vertices += [x + r * sin(th), y + r * cos(th)]
        th += 2 * pi / n
    graphics.draw(n, gl.GL_POLYGON, ('v2f', vertices), ('c4B', color * n))
コード例 #14
0
ファイル: Game.py プロジェクト: ikanreed/pyweek26
    def updateSingleMaterial(self,shader,frame_buffer, prev_frame,material):
        with frame_buffer:
            self.window.clear();#abusive, but window.clear is apparently lazy as hell in pyglet, and will wipe our frame_buffer instead
            spread_rate=0.0
            multiplier=1;
            if self.ticks%4==0:
                #multiplier=2
                pass
           
            with UniformProvider(shader,
                                previous_frame=prev_frame.textures[0], 
                                previous_status=prev_frame.textures[1],
                                previous_velocity=prev_frame.textures[2],
                                max_velocity=255.0,
                                size=[float(self.start_texture.width*multiplier), float(self.start_texture.height*multiplier)],
                                materialIndex=material.MatId,

                                #move_direction=direction.stepVector,
                                
                                #colorTolerance=0.1, #being within a unit circle 1 wide from the target color is good enough
                                #simulatedColor=material.color,
                                #spread_rate=spread_rate,
                                #max_spread=material.max_spread,
                                ):#just have to know that this is how these buffers are arranged
                graphics.draw(6,TRIANGLE, square_2d )
コード例 #15
0
ファイル: pool.py プロジェクト: xoryouyou/NetArgos
def line(a, b, color=(1.0,1.0,1.0), width=1, aa=False, alpha=1.0):
    """
    Draws a line from point *a* to point *b* using GL_LINE_STRIP optionaly with GL_LINE_SMOOTH when *aa=True*

    :param a: Point a
    :type a: 2-float tuple

    :param b: Point b
    :type b: 2-float tuple

    :param color: the color in [0..1] range
    :type color: 3-float tuple

    :param width: The with for glLineWidth()

    :param aa: Anti aliasing Flag

    :param alpha: the alpha value in [0..1] range

    """

    glLineWidth(width)
    if aa:
        glEnable(GL_LINE_SMOOTH)

    draw(2,GL_LINES,('v2f',(a[0],a[1],b[0],b[1]) ) )
コード例 #16
0
ファイル: gui.py プロジェクト: alexliberzonlab/ymage
 def draw(self):
     if self.text:
         width, height = len(self.text) * 7 + 20, 30
         graphics.draw(4, gl.GL_QUADS,
                       ("v2f", (0, 0, 0, height, width, height, width, 0)),
                       ("c4f", (1, 1, 1, 1) * 4))
     super(Printer, self).draw()
コード例 #17
0
 def draw_pause_menu(self):
     origin_x = self.width // 3
     origin_y = self.height // 5
     panel_width = self.width - 2 * origin_x
     panel_height = self.height - 2 * origin_y
     graphics.draw(4, GL_QUADS, [
         'v2f',
         [
             origin_x, origin_y, origin_x, origin_y + panel_height,
             origin_x + panel_width, origin_y + panel_height,
             origin_x + panel_width, origin_y
         ]
     ], ['c4B', tuple(GameButton.DEF_COLOR)])
     for btn in self.pause_btns:
         graphics.draw(4, GL_QUADS, [
             'v2f',
             [
                 btn.x - btn.width // 2, btn.y - btn.height // 2,
                 btn.x - btn.width // 2, btn.y + btn.height // 2,
                 btn.x + btn.width // 2, btn.y + btn.height // 2,
                 btn.x + btn.width // 2, btn.y - btn.height // 2
             ]
         ], ['c4B', tuple(btn.color)])
         btn_lbl = pyglet.text.Label(btn.lbl,
                                     font_name='8Bit Wonder',
                                     font_size=0.3 * btn.height,
                                     width=btn.width,
                                     height=0.5 * btn.height,
                                     x=btn.x,
                                     y=btn.y,
                                     anchor_x='center',
                                     anchor_y='center',
                                     color=(255, 255, 255, btn.get_alpha()))
         btn_lbl.draw()
コード例 #18
0
 def on_draw(self):
     self.window.clear()
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glPushMatrix()
     gl.glLoadIdentity()
     self.camera()
     gl.glEnable(self.grass.target)
     gl.glEnable(gl.GL_BLEND)
     gl.glBindTexture(self.grass.target, self.grass.id)
     W = 10000.
     graphics.draw(4, gl.GL_QUADS, ('v2f', (-W, -W, W, -W, W, W, -W, W)),
                   ('t2f',
                    (0., 0., W * 5., 0., W * 5., W * 5., 0., W * 5.)))
     gl.glDisable(self.grass.target)
     for lane in self.lanes:
         self.draw_lane_surface(lane)
     for lane in self.lanes:
         self.draw_lane_lines(lane)
     for obj in self.objects:
         self.draw_object(obj)
     for car in self.cars:
         if car != self.main_car and car not in self.visible_cars:
             self.draw_car(self.anim_x[car], car.color)
     if self.heat is not None:
         self.draw_heatmap()
     for car in self.cars:
         if car == self.main_car or car in self.visible_cars:
             self.draw_car(self.anim_x[car], car.color)
     gl.glPopMatrix()
     if isinstance(self.main_car, Car):
         self.label.text = 'Speed: %.2f' % self.anim_x[self.main_car][3]
         self.label.draw()
     if self.output is not None:
         pyglet.image.get_buffer_manager().get_color_buffer().save(
             self.output.format(self.frame))
コード例 #19
0
ファイル: run.py プロジェクト: msarch/py
def on_draw():
    glClear(GL_COLOR_BUFFER_BIT)
    draw(3, GL_TRIANGLES,
        ('v2f', verts),
        ('c3B', colors),
    )
    text.draw()
    clockDisplay.draw()
コード例 #20
0
ファイル: graphx.py プロジェクト: felipeCeler/reactbar
def drawTexturedRectangle(texture, pos=(0, 0), size=(1.0, 1.0)):
    glEnable(GL_TEXTURE_2D)
    glBindTexture(GL_TEXTURE_2D, texture)
    pos = (pos[0], pos[1], pos[0] + size[0], pos[1], pos[0] + size[0],
           pos[1] + size[1], pos[0], pos[1] + size[1])
    texcoords = (0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0)
    draw(4, GL_QUADS, ('v2f', pos), ('t2f', texcoords))
    glDisable(GL_TEXTURE_2D)
コード例 #21
0
 def draw_grid(self):
     gl.glColor4f(0.23, 0.23, 0.23, 1.0)
     #Horizontal lines
     for i in range(rows):
         graphics.draw(2, gl.GL_LINES, ('v2i', (0, i * cell_size, window_width, i * cell_size)))
     #Vertical lines
     for j in range(columns):
         graphics.draw(2, gl.GL_LINES, ('v2i', (j * cell_size, 0, j * cell_size, window_height)))
コード例 #22
0
def on_draw():
    window.clear()
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(-wx, wx, -wy, wy, -20, 20)
    glRotatef(90, 1, 0, 0)
    graphics.draw(4, GL_QUADS, ('v3f', (v0 + v1 + v2 + v3)),
                  ('t2f', t0 + t1 + t2 + t3))
コード例 #23
0
ファイル: scene.py プロジェクト: gridl/battlegrounds
 def draw_shape_triangle(self, triangle, position):
     glPushMatrix()
     glTranslatef(position.x, position.y, 0)
     points = []
     for point in triangle.points:
         points.extend((point.x, point.y))
     draw(3, GL_LINE_LOOP, ('v2f', points))
     glPopMatrix()
コード例 #24
0
 def draw(self, window):
     w, h = window.width/2, window.height/2
     graphics.draw(2, gl.GL_LINES, 
     ('v2f', [(self.origin[0]+w),
              (self.origin[1]+h),
              (self.endpoint[0]+w), 
              (self.endpoint[1]+h)]),
     ('c3f', self.color*2))
コード例 #25
0
ファイル: shapes.py プロジェクト: B-Rich/chemlab
 def draw(self):
     indexed = [0, 1, 2, 1, 2, 3, 4, 5, 6]
     
     triangles = len(indexed)
     draw(triangles, pyglet.gl.GL_TRIANGLES,
          ("v3f", self.vertices[indexed,].flatten()),
          ("n3f", self.normals[indexed,].flatten()),
          ("c3B", self.color*triangles))
コード例 #26
0
ファイル: connect4.py プロジェクト: retrosnob/pyglet_games
def draw_line(x1, y1, x2, y2, color=(255, 255, 255, 0)):
    """Draws a line from x1, y1 to x2, y2"""
    # 2 means that 2 vertices will be supplied, the mode is line drawing
    # v2i means (v)ertices, (2) coordinates per vertex ie 2D, each vertex is an (i)nteger
    # c3B means (c)olor, (4) values per vertex ie RGBA, unsigned (B)yte representation
    # there has to be one color per vertex, so in this case 2 lots of 4 values
    graphics.draw(2, gl.GL_LINES, ('v2i', (x1, y1, x2, y2)),
                  ('c4B', color * 2))
コード例 #27
0
ファイル: scene.py プロジェクト: gridl/battlegrounds
 def draw_shape_aabb(self, aabb, position):
     glPushMatrix()
     glTranslatef(position.x, position.y, 0)
     x_min, y_min, x_max, y_max = \
         aabb.min.x, aabb.min.y, aabb.max.x, aabb.max.y
     draw(4, GL_LINE_LOOP,
          ('v2f', (x_min, y_min, x_min, y_max, x_max, y_max, x_max, y_min)))
     glPopMatrix()
コード例 #28
0
ファイル: shapes.py プロジェクト: moxon6-experiments/chemlab
    def draw(self):
        indexed = [0, 1, 2, 1, 2, 3, 4, 5, 6]

        triangles = len(indexed)
        draw(triangles, pyglet.gl.GL_TRIANGLES,
             ("v3f", self.vertices[indexed, ].flatten()),
             ("n3f", self.normals[indexed, ].flatten()),
             ("c3B", self.color * triangles))
コード例 #29
0
 def render(self):
     if (self.toggled):
         glColor4f(*const.COLOR_BUTTON_TOGGLED)
     else:
         glColor4f(*const.COLOR_BUTTON)
     draw(4, GL_QUADS, ('v2f', self.gl_vertices))
     glColor4f(*const.COLOR_BUTTON_BORDER)
     draw(4, GL_LINE_LOOP, ('v2f', self.gl_vertices))
     self.label.draw()
コード例 #30
0
ファイル: scene.py プロジェクト: gridl/battlegrounds
 def draw_shape_polygon(self, polygon, position):
     glPushMatrix()
     glTranslatef(position.x, position.y, 0)
     points = polygon.points
     p = []
     for point in points:
         p.extend((point.x, point.y))
     draw(len(points), GL_TRIANGLE_FAN, ('v2f', p))
     glPopMatrix()
コード例 #31
0
ファイル: base_view.py プロジェクト: frlnx/melee
 def _draw_bbox(bbox, color: Tuple[int, int, int, int]=None):
     color = color or (255, 255, 255, 255)
     lines = bbox.lines
     v3f = [(line.x1, -10.0, line.y1, line.x2, -10.0, line.y2) for line in lines]
     v3f = list(chain(*v3f))
     n_points = int(len(v3f) / 3)
     v3f = ('v3f', v3f)
     c4b = ('c4B', color * n_points)
     draw(n_points, GL_LINES, v3f, c4b)
コード例 #32
0
ファイル: ui.py プロジェクト: NiclasEriksen/py-towerwars
 def render(self):
     self.w.batches["mm_buttons"].draw()
     gl.glClear(gl.GL_COLOR_BUFFER_BIT)
     gl.glColor3f(0.3, 0.3, 0.3, 1)
     for e in self.entries:
         graphics.draw(
             4, gl.GL_QUADS, ('v2i', e.rectangle)
         )
         e.label.draw()
コード例 #33
0
ファイル: coverflow.py プロジェクト: azoon/pymt
def drawCover(texture, pos=(0,0), size=(1.0,1.0)):
    with gx_texture(texture):
        pos = ( pos[0],pos[1],   pos[0]+size[0],pos[1],   pos[0]+size[0],pos[1]+size[1],  pos[0],pos[1]+size[1] )
        texcoords = (0.0,0.0, 1.0,0.0, 1.0,1.0, 0.0,1.0)
        draw(4, GL_QUADS, ('v2f', pos), ('t2f', texcoords))
        pos2 = ( pos[0],pos[1]-size[1],   pos[0]+size[0],pos[1]-size[1],   pos[0]+size[0],pos[1]+size[1]-size[1],  pos[0],pos[1]+size[1]-size[1] )
        texcoords2 = (0.0,1.0, 1.0,1.0, 1.0,0.0, 0.0,0.0)
        color2 = (0,0,0,0.5, 0,0,0,0.5, 0.65,0.65,0.65,0.5, 0.65,0.65,0.65,0.5 )
        draw(4, GL_QUADS, ('v2f', pos2), ('t2f', texcoords2), ('c4f', color2))
コード例 #34
0
ファイル: ui.py プロジェクト: NiclasEriksen/rpg_procgen
 def draw(self):
     if self.window.debug and not self.hidden:
         gl.glColor4f(*self.color)
         graphics.draw(4, gl.GL_QUADS, ('v2f', self.rectangle))
         if not self.fg_batch:
             for l in self.stat_labels_l:
                 l.draw()
             for l in self.stat_labels_r:
                 l.draw()
コード例 #35
0
ファイル: scroller.py プロジェクト: azoon/pymt
def drawCover(texture, pos=(0,0), size=(1.0,1.0)):
    with gx_texture(texture):
        pos = ( pos[0],pos[1],   pos[0]+size[0],pos[1],   pos[0]+size[0],pos[1]+size[1],  pos[0],pos[1]+size[1] )
        texcoords = (0.0,0.0, 1.0,0.0, 1.0,1.0, 0.0,1.0)
        draw(4, GL_QUADS, ('v2f', pos), ('t2f', texcoords))
        set_color(1, 1, 1, 0.999, dfactor=GL_ONE_MINUS_SRC_COLOR)
        pos2 = ( pos[0],pos[1]-size[1],   pos[0]+size[0],pos[1]-size[1],   pos[0]+size[0],pos[1]+size[1]-size[1],  pos[0],pos[1]+size[1]-size[1] )
        texcoords2 = (0.0,1.0, 1.0,1.0, 1.0,0.0, 0.0,0.0)
        color2 = (0,0,0,0.5, 0,0,0,0.5, 0.65,0.65,0.65,0.5, 0.65,0.65,0.65,0.5 )
        draw(4, GL_QUADS, ('v2f', pos2), ('t2f', texcoords2), ('c4f', color2))
コード例 #36
0
def drawCover(texture, pos=(0,0), size=(1.0,1.0)):
    with gx_enable(GL_TEXTURE_2D):
        glBindTexture(GL_TEXTURE_2D,texture)
        pos = ( pos[0],pos[1],   pos[0]+size[0],pos[1],   pos[0]+size[0],pos[1]+size[1],  pos[0],pos[1]+size[1] )
        texcoords = (0.0,0.0, 1.0,0.0, 1.0,1.0, 0.0,1.0)
        draw(4, GL_QUADS, ('v2f', pos), ('t2f', texcoords))
        pos2 = ( pos[0],pos[1]-size[1],   pos[0]+size[0],pos[1]-size[1],   pos[0]+size[0],pos[1]+size[1]-size[1],  pos[0],pos[1]+size[1]-size[1] )
        texcoords2 = (0.0,1.0, 1.0,1.0, 1.0,0.0, 0.0,0.0)
        color2 = (0,0,0,0.5, 0,0,0,0.5, 0.5,0.5,0.5,0.5, 0.5,0.5,0.5,0.5 )
        draw(4, GL_QUADS, ('v2f', pos2), ('t2f', texcoords2), ('c4f', color2))
コード例 #37
0
ファイル: main.py プロジェクト: severokST/Maze
def on_draw():
    main_window.clear()
    UI['batch_actors'].draw()
    UI['batch_map'].draw()
    graphics.draw(4, gl.GL_LINE_LOOP, ('v2i', [
        UI['Field']['position'][0], UI['Field']['position'][1],
        UI['Field']['position'][0]+UI['Field']['size'][0], UI['Field']['position'][1],
        UI['Field']['position'][0]+UI['Field']['size'][0], UI['Field']['position'][1]+UI['Field']['size'][1],
        UI['Field']['position'][0], UI['Field']['position'][1]+UI['Field']['size'][1],
    ]))
コード例 #38
0
ファイル: tnt.py プロジェクト: Minecraft-in-python/Minecraft
 def on_draw(self):
     vertex_data = cube_vertices(*self._data['position'], 1, 1)
     if self._show:
         glColor3f(1.0, 1.0, 1.0)
     else:
         glColor3f(0.64, 0.16, 0.16)
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
     glDisable(GL_CULL_FACE)
     graphics.draw(24, GL_QUADS, ('v3f/static', vertex_data))
     glEnable(GL_CULL_FACE)
コード例 #39
0
def on_draw():
    glClear(GL_COLOR_BUFFER_BIT)
    draw(
        3,
        GL_TRIANGLES,
        ('v2f', verts),
        ('c3B', colors),
    )
    text.draw()
    clockDisplay.draw()
コード例 #40
0
ファイル: visualize.py プロジェクト: GitHubUserH01/LAC
    def on_draw(self):
        self.window.clear()

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        self.camera()

        gl.glEnable(self.grass.target)
        gl.glEnable(gl.GL_BLEND)

        gl.glBindTexture(self.grass.target, self.grass.id)  # 纹理绑定
        W = 10000.

        graphics.draw(4, gl.GL_QUADS, ('v2f', (-W, -W, W, -W, W, W, -W, W)),
                      ('t2f',
                       (0., 0., W * 5., 0., W * 5., W * 5., 0., W * 5.)))

        gl.glDisable(self.grass.target)

        if self.turn_flag:
            self.leader_list = rl_loop.check_leader(self.auto_anim_x,
                                                    self.human_anim_x)
        else:
            self.leader_list = [0 for i in range(5)]

        #print(leader_list)

        for lane in self.lanes:
            self.draw_lane_surface(lane)
        for lane in self.lanes:
            self.draw_lane_lines(lane)

        for obj in self.objects:
            self.draw_object(self.obj_anim_x[obj])

        for no, car in enumerate(self.human_cars):
            self.draw_car(self.human_anim_x[no], car.color)

        for no, car in enumerate(self.auto_cars):
            # if self.leader_list[no] == 1:
            #     self.draw_car(self.auto_anim_x[no], 'purple')
            # else:
            self.draw_car(self.auto_anim_x[no], car.color)

        for no, car in enumerate(self.mock):
            if self.mock_anim_x[no][1] >= -0.8:
                self.draw_car(self.mock_anim_x[no], car.color)

        # for car in self.SEKIRO:
        #     self.draw_car(car, 'yellow', opacity=50)

        # if self.heat is not None:
        #     self.draw_heatmap()
        gl.glPopMatrix()
コード例 #41
0
def draw_turn_bar():
    # This just draws a thin bar at the top of the grid to show whose turn it is.
    if player == 1:
        color = P1_COLOR
    elif player == 2:
        color = P2_COLOR
    graphics.draw(4, gl.GL_POLYGON,
                  ('v2i',
                   (0, WIN_HEIGHT + TURN_BAR_HEIGHT, WIN_WIDTH, WIN_HEIGHT +
                    TURN_BAR_HEIGHT, WIN_WIDTH, WIN_HEIGHT, 0, WIN_HEIGHT)),
                  ('c4B', color * 4))
コード例 #42
0
 def show(self):
     pg.draw(
         1,
         pyglet.gl.GL_POINTS,
         (
             'v2f',
             (
                 self.x,
                 self.y  # center dot
             )),
         ('c3B', (0, 0, 255)))
コード例 #43
0
ファイル: ui.py プロジェクト: NiclasEriksen/rpg_procgen
 def draw(self):
     try:
         gl.glEnable(gl.GL_BLEND)
         gl.glColor4f(*self.color)
         graphics.draw(4, gl.GL_QUADS, ('v2f', self.rectangle))
         gl.glDisable(gl.GL_BLEND)
         # self.label.draw()
     except AttributeError as e:
         self.window.logger.debug(
             "Bar is not ready to be drawn: {0}".format(e)
         )
コード例 #44
0
def quad(width, height):
    draw(4, GL_QUADS, 
        ('v2f', (
            0, 0,
            width, 0,
            width, height,
            0, height,
        )),
        ('t2f', (
            0, 0,
            1, 0,
            1, 1,
            0, 1,
        )),
    )
コード例 #45
0
ファイル: renderer.py プロジェクト: erebuswolf/IGVC-Code
    def on_draw(self, creatures, camera, win_width, win_height):
        glClear(GL_COLOR_BUFFER_BIT)
        camera.update_position()
        camera.focus(win_width, win_height)

        for creature in creatures:

            glPushMatrix()
            glTranslatef(creature.x, creature.y, 0)
            glRotatef(creature.angle * rad2deg, 0, 0, 1)

            if self.rendermode == RenderMode.BATCH:
                batch = creature.shape.get_batch()
                batch.draw()
            else:

                for primitive in creature.shape.primitives:

                    if self.rendermode == RenderMode.VERTEXLIST:

                        vertexlist = primitive.get_vertexlist()
                        vertexlist.draw(primitive.primtype)

                    elif self.rendermode == RenderMode.DRAW:

                        flatverts = primitive.get_flat_verts()
                        numverts = int(len(flatverts) / 2)
                        draw(
                            numverts,
                            primitive.primtype,
                            ('v2f/static', flatverts),
                            ('c3B/static', primitive.color * numverts),
                        )

                    elif self.rendermode == RenderMode.GLVERTEX:

                        glColor3ub(*primitive.color)
                        glBegin(primitive.primtype)
                        for vert in primitive.verts:
                            glVertex2f(*vert)
                        glEnd()

            glPopMatrix()

        camera.hud_mode(win_width, win_height)
        clockDisplay.draw()
コード例 #46
0
ファイル: Liquid.py プロジェクト: ramsay/ramsay-snippets
 def on_draw():
     '''The draw command is one glDraw command after gathering all of the 
     vertex information from the simulation. The draw loop first draws the 
     lines in simulation coordinates which is then "scaled" up using 
     glMatrixmode.'''
     window.clear()
     vertices = []
     colors = []
     for p in liquid.particles:
         vertices.extend([p.x, p.y, p.x - p.u, p.y - p.v])
         colors.extend(p.color)
         colors.extend([0, 0, 0])
     graphics.draw(
         len(liquid.particles)*2,
         gl.GL_LINES,
         ('v2f', vertices),
         ('c3B', colors)
     )
     gl.glMatrixMode(gl.GL_PROJECTION)
     gl.glLoadIdentity()
     gl.glOrtho(0, liquid.width, liquid.height, 0, -1, 1)
     gl.glMatrixMode(gl.GL_MODELVIEW)
コード例 #47
0
ファイル: ui.py プロジェクト: NiclasEriksen/rpg_procgen
    def draw(self):
        if self.settings["draw_mob_hp"]:
            gl.glColor4f(*lookup_color("red", gl=True))
            gl.glLineWidth(3)
            for e in self.window.game.enemies:
                if e.hp < e.max_hp or self.settings["allways_draw_mob_hp"]:
                    wpos = self.window.get_windowpos(
                        e.x, e.y + e.sprite.height,
                        check=True, tol=32, precise=True
                    )
                    if wpos:
                        width = (e.hp / e.max_hp) * e.sprite.width
                        graphics.draw(
                            2,
                            gl.GL_LINES,
                            (
                                'v2f',
                                (
                                    wpos[0] - width / 2,
                                    wpos[1],
                                    wpos[0] + width / 2,
                                    wpos[1])
                                )
                        )

        # for b in self.buttons:
        #     b.draw()
        self.bg_batch.draw()
        if self.window.game.player:
            for b in self.bars:
                b.draw()
            self.bar_fg_batch.draw()
        if self.stats:
            self.stats.draw()
        for b in self.progressbars:
            b.draw()
        self.fg_batch.draw()
        if self.target_label:
            self.target_label.draw()
コード例 #48
0
 def draw_heatmap(self):
     if not self.heatmap_show:
         return
     SIZE = (256, 256)
     if not self.heatmap_valid:
         o = self.center()
         x0 = o-np.asarray([1.5, 1.5])/self.magnify
         x0 = np.asarray([x0[0]-x0[0]%(1./self.magnify), x0[1]-x0[1]%(1./self.magnify)])
         x1 = x0+np.asarray([4., 4.])/self.magnify
         x0 = o-np.asarray([1., 1.])/self.magnify
         x1 = o+np.asarray([1., 1.])/self.magnify
         self.heatmap_x0 = x0
         self.heatmap_x1 = x1
         vals = np.zeros(SIZE)
         for i, x in enumerate(np.linspace(x0[0], x1[0], SIZE[0])):
             for j, y in enumerate(np.linspace(x0[1], x1[1], SIZE[1])):
                 vals[j, i] = self.heat(np.asarray([x, y]))
         vals = (vals-np.min(vals))/(np.max(vals)-np.min(vals)+1e-6)
         vals = self.cm(vals)
         vals[:,:,3] = 0.7
         vals = (vals*255.99).astype('uint8').flatten()
         vals = (gl.GLubyte * vals.size) (*vals)
         img = pyglet.image.ImageData(SIZE[0], SIZE[1], 'RGBA', vals, pitch=SIZE[1]*4)
         self.heatmap = img.get_texture()
         self.heatmap_valid = True
     gl.glClearColor(1., 1., 1., 1.)
     gl.glEnable(self.heatmap.target)
     gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
     gl.glBindTexture(self.heatmap.target, self.heatmap.id)
     gl.glEnable(gl.GL_BLEND)
     x0 = self.heatmap_x0
     x1 = self.heatmap_x1
     graphics.draw(4, gl.GL_QUADS,
         ('v2f', (x0[0], x0[1], x1[0], x0[1], x1[0], x1[1], x0[0], x1[1])),
         ('t2f', (0., 0., 1., 0., 1., 1., 0., 1.)),
         #('t2f', (0., 0., SIZE[0], 0., SIZE[0], SIZE[1], 0., SIZE[1]))
     )
     gl.glDisable(self.heatmap.target)
コード例 #49
0
ファイル: treeDrawer.py プロジェクト: Poroing/ProTree
def drawOrientedRectangle(x, y, dir_x, dir_y, width, height, r, g, b, a):
	"""Draw an oriented rectangle 
	
	Args:
		x: A floating point indicating the rectangle's x position in window
		coordinate
		y: A floating point indicating the rectangle's y position in window
		coordinate 
		dir_x: A floating point that represent the x coordinate of the vertor
			that give the direction relative to the rectangle's position of the
			side that have the height as length
		dir_y: A floating point that represent the y coordinate of the vertor
			that give the direction relative to the rectangle's position of the
			side that have the height as length
		width: A float indicating the rectangle's width
		height: A float indicating the rectangle's height
		r: An integer in the range [0, 255] that represent the rectangle's
			color's red component
		g: An integer in the range [0, 255] that represent the rectangle's
			color's green component
		b: An integer in the range [0, 255] that represent the rectangle's
			color's blue component
		a: An integer in the range [0, 255] that represent the rectangle's
			color's alpha component
	"""

	dir_length = sqrt(dir_x ** 2 + dir_y ** 2)
	dir_x = dir_x / dir_length
	dir_y = dir_y / dir_length

	draw(4, GL_TRIANGLE_STRIP,
        #Vertices of a rectangle in which the right side is diriged by dir
        ('v2f', (x, y,
                 x + width * dir_y, y - width * dir_x,
                 x + height * dir_x, y + height * dir_y,
                 x + width * dir_y + height * dir_x,
                 y + height * dir_y - width * dir_x)),
        ('c4B', ((r, g, b, a) * 4)))
コード例 #50
0
ファイル: newlauncher.py プロジェクト: patali/toccoui
def drawCover(texture, pos=(0, 0), size=(1.0, 1.0)):
    with gx_enable(GL_TEXTURE_2D):
        glBindTexture(GL_TEXTURE_2D, texture)

        # Draw First Cover
        pos = (pos[0], pos[1], pos[0] + size[0], pos[1], pos[0] + size[0], pos[1] + size[1], pos[0], pos[1] + size[1])
        texcoords = (0.0, 0.0, 0.90, 0.0, 0.9, 0.9, 0.0, 0.9)
        draw(4, GL_QUADS, ("v2f", pos), ("t2f", texcoords))

        # Draw Second Cover
        pos2 = (
            pos[0],
            pos[1] - size[1],
            pos[0] + size[0],
            pos[1] - size[1],
            pos[0] + size[0],
            pos[1] + size[1] - size[1],
            pos[0],
            pos[1] + size[1] - size[1],
        )
        texcoords2 = (0.0, 0.9, 0.9, 0.9, 0.9, 0.0, 0.0, 0.0)
        color2 = (0, 0, 0, 0, 0, 0, 0, 0, 0.4, 0.4, 0.4, 0, 0.4, 0.4, 0.4, 0)
        draw(4, GL_QUADS, ("v2f", pos2), ("t2f", texcoords2), ("c4f", color2))
コード例 #51
0
ファイル: AC_model.py プロジェクト: atwel/Autocatalysis_GUI
def on_draw():
    rule_plot_window.clear()
    for bar in rule_bars:
        graphics.glColor3f(0, 0, 255)
        graphics.draw(4, pyg.gl.GL_QUADS, ('v2f', bar))

    graphics.glColor3f(0, 0, 0)
    graphics.glLineWidth(3)
    graphics.draw(2, pyg.gl.GL_LINES, ('v2f', (10.,30., 380., 30.)))
    graphics.draw(2, pyg.gl.GL_LINES, ('v2f',(10.,29., 10., 255)))
コード例 #52
0
#!/usr/bin/python
# $Id:$

from pyglet.gl import *
from pyglet import graphics
from pyglet import window

win = window.Window()

while not win.has_exit:
    win.dispatch_events()
    win.clear()
    graphics.draw(3, GL_TRIANGLES,
        ('v2f', [10., 10., 
                 100., 10., 
                 100., 100.]),
        ('c3B', [255, 0, 0,
                 0, 255, 0,
                 0, 0, 255]))
    win.flip()
コード例 #53
0
ファイル: render.py プロジェクト: ddunwoody/cayley
def draw_line_loop(vertices):
    draw(len(vertices) / 2, GL_LINE_LOOP, ('v2f', vertices))
コード例 #54
0
ファイル: render.py プロジェクト: ddunwoody/cayley
def draw_lines(vertices):
    draw(len(vertices) / 2, GL_LINES, ('v2f', vertices))
コード例 #55
0
ファイル: render.py プロジェクト: ddunwoody/cayley
def draw_polygon(vertices):
    draw(len(vertices) / 2, GL_POLYGON, ('v2f', vertices))
    draw_line_loop(vertices)
コード例 #56
0
ファイル: gesture.py プロジェクト: pdevine/air-control
 def draw(self):
     vertices = len(self.coords) / 2
     draw(vertices, pyglet.gl.GL_POINTS, ('v2i', tuple(self.coords)))
コード例 #57
0
ファイル: draw.py プロジェクト: bluepnume/pyp
def line(start, end):
  glEnable(GL_LINE_SMOOTH);
  #glLineWidth(2)  
  draw(2, GL_LINES, ('v2i', map(int, start + end)))
コード例 #58
0
ファイル: characters.py プロジェクト: ceronman/prisionescape
    def draw(self):
        self.sprite.draw()

        if configuration.DEBUG:
            glColor4f(1, 0, 0, 1)
            draw(4, GL_POINTS, ("v2i", self.rect.points))
コード例 #59
0
ファイル: objects.py プロジェクト: kearnh/pqrs
 def draw(self):
     gl.glColor3f(1, 0, 0)
     x, y, h, w = int(self.x), int(self.y), int(self.height), int(self.width)
     graphics.draw(4, gl.GL_LINE_LOOP, ('v2i', (x, y, x+w, y, x+w, y+h, x, y+h)))