import pyxel import numpy as np SEGMENTS = 1000 pyxel.init(400, 400) pyxel.colors[0] = 0xcecece pyxel.colors[1] = 0x370028 pyxel.cls(0) def bezier_point(vec_ctrls, t): p = (1-t)**3 * vec_ctrls[0] + 3*(1-t)**2*t * vec_ctrls[1] + \ 3*(1-t)*t**2 * vec_ctrls[2] + t**3 * vec_ctrls[3] return p def trace(pt_ctrls): vec_ctrls = np.array(pt_ctrls) for i in range(SEGMENTS+1): t = i/SEGMENTS p = bezier_point(vec_ctrls, t) pyxel.circ(*p, 1) points_du_controle = [ [350, 50, 0], [0, 0, 5], [0, 0, 5], [50, 350, 0] ] trace(points_du_controle) pyxel.show()