Answer the question
In order to leave comments, you need to log in
How to perform an asynchronous function call in Python?
I want to write a prank for friends related to the gradual dimming of the screen. The code:
import pyautogui
from win32gui import SetPixel, GetDC
from pywintypes import error
from win32api import RGB
from random import randint as rnd
color = (0, 0, 0)
dc = GetDC(0)
def effect(dc, x, y, color):
SetPixel(dc, x, y, color)
for times in range(1000):
s = pyautogui.screenshot()
for x in range(s.width):
for y in range(s.height):
if s.getpixel((x, y)) == color:
try:
effect(dc, x + rnd(1, 10), y + rnd(1, 10), RGB(color[0], color[1], color[2]))
except error:
pass
Answer the question
In order to leave comments, you need to log in
Pixel drawing is very slow, how can I fix this?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question