renpy / pygame_sdl2

Reimplementation of portions of the pygame API using SDL2.
GNU Lesser General Public License v2.1
329 stars 66 forks source link

draw.rect() draws 1 pixel wider and taller boxes in Pygame_SDL2 than Pygame #30

Closed runedevros closed 5 months ago

runedevros commented 8 years ago

Noticed this since some of Lost Sky's UI elements looked a little off.

The image "black.png" used in this script is here:

black

The following code fills the screen with black, draws a white 64x64 square and then blits black.png, a 64x64 pixel image on top of it.


# Comment out these two lines to go back to old Pygame version
import pygame_sdl2
pygame_sdl2.import_as_pygame()

import pygame
from pygame import KEYDOWN, QUIT
import sys

def main():

    pygame.init()
    tilesize = 35
    size_x = 24
    size_y = 18
    screen_size = (tilesize * size_x, tilesize * size_y)
    screen = pygame.display.set_mode(screen_size, 0, 32)
    clock = pygame.time.Clock()

    black_square = pygame.image.load('black.png')

    stop_flag = False

    while not stop_flag:

        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit()

        screen.fill((0,0, 0))

        pygame.draw.rect(screen, (255, 255, 255), (100, 100, 64, 64))
        screen.blit(black_square, (100,100))

        pygame.display.flip()

        clock.tick(60)

if __name__ == '__main__':
    main()

In Pygame, we get as expected a completely black screen.

screen shot 2016-01-25 at 9 50 37 pm

But in PygameSDL2, there is a 1 pixel think | shaped thing where the rect is drawn one pixel too big.

screen shot 2016-01-25 at 9 49 57 pm