add mixbox for python

This commit is contained in:
Ondrej Jamriska
2022-09-21 05:05:52 +02:00
parent 4bfc462204
commit 334932d8fe
7 changed files with 384 additions and 0 deletions

29
python/examples/opengl.py Normal file
View File

@@ -0,0 +1,29 @@
import pygame as pg
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
import mixbox
pg.init()
pg.display.set_mode((640, 480), DOUBLEBUF | OPENGL)
while True:
rgb1 = (0.0, 0.129, 0.522) # blue
rgb2 = (0.988, 0.827, 0.0) # yellow
n = 640
glBegin(GL_LINES)
for i in range(0, n+1):
glColor(mixbox.lerp_float(rgb1, rgb2, i / n))
glVertex((i / n)*2 - 1, -1)
glVertex((i / n)*2 - 1, +1)
glEnd()
pg.display.flip()
for event in pg.event.get():
if event.type == pg.QUIT:
pg.quit()
quit()