vssg/video.py

69 lines
No EOL
1.1 KiB
Python

import pygame
updatelist = []
force_full = False
g_scr = None
def get_forced_redraw():
global force_full
return force_full
def force_redraw():
"""
>>> force_redraw() -> None
forces a fullscreen update (slow! use with care)
"""
global updatelist, force_full
updatelist = []
force_full = True
def update(r):
"""
>>> update(rect) -> None
queues the given rectangle(s) for an update
"""
global updatelist, force_full
if force_full:
return
if type(r) == tuple:
r = list(r)
elif type(r) != list:
r = [r]
updatelist += r
if len(updatelist) > 100:
force_full = True
updatelist = []
def next_frame():
"""
>>> next_frame() -> None
finalizes and draws the next frame
"""
global updatelist, force_full
if force_full:
print("Doing FULL redraw!")
pygame.display.flip()
else:
pygame.display.update(updatelist)
updatelist = []
force_full = False
def set_scr(scr):
"""
>>> set_scr(scr) -> None
sets the main screen (turn on?)
"""
global g_scr
g_scr = scr
def get_scr():
"""
>>> get_scr() -> pygame.Surface
gets the screen
"""
global g_scr
return g_scr