Example #1
0
def main(stdscr):
    curses.curs_set(0)

    win_height, win_width = stdscr.getmaxyx()
    pix_height = win_height * 4 - win_height % 4
    pix_width = win_width * 2 - win_width % 2

    arr = []
    for i in range(pix_height):
        row = []
        for j in range(pix_width):
            row.append(0)
        arr.append(row)

    last_frame = time.time()
    while True:
        # Clear the screen
        stdscr.refresh()
        stdscr.erase()
        for i in range(pix_height):
            for j in range(pix_width):
                arr[i][j] = 0

        # Draw
        graphics.draw_circle(arr, [pix_width / 6, pix_height / 8],
                             min(pix_width / 6, pix_height / 8))
        graphics.draw_square(arr, [pix_width / 2, pix_height / 8],
                             min(pix_width / 6, pix_height / 8))
        graphics.draw_ellipse(arr, [5 * pix_width / 6 - 1, pix_height / 4],
                              pix_width / 12, pix_height / 4)
        graphics.draw_ellipse(arr, [pix_width / 3, 3 * pix_height / 8],
                              pix_width / 3, pix_height / 8)
        graphics.draw_polygon(arr, [pix_width / 3, 5 * pix_height / 8 + 3],
                              min(pix_width / 4, pix_height / 8),
                              3,
                              angle_offset=-90)
        graphics.draw_polygon(arr, [2 * pix_width / 3, 5 * pix_height / 8 + 3],
                              min(pix_width / 4, pix_height / 8),
                              7,
                              angle_offset=13)
        graphics.draw_rectangle(arr, [pix_width / 9, pix_height - 2],
                                [2 * pix_width / 9, 3 * pix_height / 4])
        graphics.draw_rectangle(arr, [2 * pix_width / 3, 5 * pix_height / 6],
                                [pix_width - 2, 11 * pix_height / 12])
        graphics.draw_polygon(arr, [pix_width / 2, 7 * pix_height / 8],
                              min(pix_width / 6, pix_height / 8),
                              5,
                              angle_offset=-18)

        # Render
        chars = array_to_pixels(arr)

        for i in range(win_height - 1):
            for j in range(win_width - 1):
                stdscr.addstr(i, j, chars[i][j])

        # Show FPS
        now = time.time()
        stdscr.addstr(0, 0, f'FPS: {int(1/(now - last_frame))}')
        last_frame = now
Example #2
0
 def render(self):
     glPushMatrix()
     glTranslatef(self.position.x, self.size / 2.0, self.position.z)
     glRotatef(self.rotation, 0.0, 1.0, 0.0)
     glColor3f(*self.color)
     glutSolidCube(self.size)
     glPopMatrix()
     graphics.draw_circle(self.position, self.radius, (195.0 / 255, 1.0 / 255, 243.0 / 255))
     self.velocity.set_length(0)
Example #3
0
 def draw(self, screen, field, color):
     draw_circle(screen, field, color, self.center, self.radius)
Example #4
0
#hector.pencolor(0.71, 0.76, 0.228)
hector.pencolor(255, 0, 0)
graphics.draw_square(hector, 100)

graphics.move_turtle(hector, -100, 100)

hector.pencolor(0, 255, 0)
graphics.draw_polygon(hector, 50, 8)

graphics.move_turtle(hector, 200, 200)

# a circle using the draw_polygon()
#graphics.draw_polygon(hector, 1, 360)

hector.pencolor(255, 255, 0)
graphics.draw_circle(hector, 32)














Example #5
0
 def draw(self, screen, field, color):
     draw_circle(screen, field, color, self.center, self.radius)