やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

pygameの直線描画における問題

pygameで線を描くときに生じる問題。

問題

f:id:ytyaru:20170728170120p:plain

上半分がシマシマになる。なにこれ……。

ソースコード

#!python3.6
# coding: utf-8
import sys, copy, pygame
from pygame.locals import *

#pygame.draw.line(Surface, color, start_pos, end_pos, width=1): return Rect
#pygame.draw.lines(Surface, color, closed, pointlist, width=1): return Rect

class Screen:
    def __init__(self):
        self.__color = (0,0,0)
        self.__size = (320, 240)
        self.__screen = pygame.display.set_mode(self.__size)
    @property
    def Screen(self): return self.__screen
    def Fill(self): self.__screen.fill(self.__color)

pygame.init()
pygame.display.set_caption("塗り漏れが生じる")
screen = Screen()
clock = pygame.time.Clock()
while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: pygame.quit(); sys.exit();
    screen.Fill()
#    pygame.draw.line(screen.Screen, [255,255,255], [0,0], [300, 200], 1)
    pygame.draw.line(screen.Screen, [255,255,255], [0,0], [300, 200], 64) #widthを1以外にすると塗り漏れが生じる
    pygame.display.flip()
    clock.tick(60) # 60 FPS

所感

塗り漏れはひどすぎる。どうしてこうなるのか謎。綺麗な白い線を引きたいのに。