traj.py

Created by schraf

Created on January 19, 2025

857 Bytes

Ma playlist de jeux et de tutos pour la NUMWORKS

Vidéo TikTok sur une vraie machine


from cmath import *
from kandinsky import *
from random import random
from time import sleep

def orbits(x,y):
   c = x + y * 1j
   z = 0j
   i = 1
   ptx, pty = [], []
   while i < 200 and abs(z) < 2:
      ptx.append(z.real)
      pty.append(z.imag)
      z = z ** 2 + c
      i += 1
   minx, maxx = min(ptx), max(ptx)
   miny, maxy = min(pty), max(pty)
   try:
      echx = 320 / (maxx - minx)
      echy = 222 / (maxy - miny)
      for i in range(len(ptx)):
       x = int((maxx - ptx[i]) * echx)
       y = 222 - int((maxy - pty[i]) * echy)
       set_pixel(x, y, (255,255,0))
   except: return 

u,v = random()-.5, random()-.5
du, dv = 1, 1
while True:
 fill_rect(0,0,320,222,(0,0,0))
 for _ in range(20):
  orbits(u, v)
  u += du * random()/100
  if abs(u) > .7: du = -du
  v += dv * random()/100
  if abs(v) > .7: dv = -dv  
 sleep(.001)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.