예제 #1
0
def sphere(col, pos, rad):
    x, y = pos
    rect = pygame.Rect(x - rad, y - rad, rad * 2, rad * 2)
    for i in range(-rad, rad):
        for j in range(-rad, rad):
            if i * i + j * j < rad * rad:
                pixel(col, (x + i, y + j))
    pygame.dirty_rects.append(rect)
    return rect
예제 #2
0
def num(n, size, pos):
    x, y = pos
    pixelart = getpixels(n)
    for i, row in enumerate(pixelart):
        for j, b in enumerate(row):
            if b:
                for k in range(size):
                    for k2 in range(size):
                        pixel(BLUE, (x + j * size + k, y + i * size + k2))

    rect = pygame.Rect(x, y, size * len(pixelart[0]), size * len(pixelart))
    pygame.dirty_rects.append(rect)
    return rect
예제 #3
0
def square(rect, col=WHITE, thickness=1):
    for i in range(rect.width):
        for k in range(thickness):
            pixel(col, (rect.left + i, rect.top + k))
            pixel(col, (rect.left + i, rect.bottom - 1 - k))

    for i in range(rect.height):
        for k in range(thickness):
            pixel(col, (rect.left + k, rect.top + i))
            pixel(col, (rect.right - 1 - k, rect.top + i))
    pygame.dirty_rects.append(rect)