Home > Back-end >  Square in Python GDI (with PatBLT)
Square in Python GDI (with PatBLT)

Time:02-28

Hey there!

How do I create squares in Python GDI? (with PatBLT)

So I am having some fun with pywin32.
I am trying to make a sqaure to make some fun GDI effects
Heres what I have tried so far:

from win32gui import *
from win32api import *
from win32ui import *
from win32con import *


desk = GetDC(0)
x = 100
y = 100
x_2 = 100
y_2 = 100


for i in range(5):
    PatBlt(desk, x, y, x_2, y_2, PATINVERT)
    x  = 10
    y  = 10
    x_2 -= 10
    y_2 -= 10

and instead of something like this:

0 0 0 0 0
0 X X X 0
0 X 0 X 0
0 X X X 0
0 0 0 0 0

I am getting something like this:

0 0 0 0 0
0 X X X X
0 X 0 0 0
0 X 0 0 0
0 X 0 0 0

And I should be getting the expected results... but I am not. Does anyone know why?

CodePudding user response:

According to enter image description here

  • Related