tests5.py

Created by elnix91

Created on February 28, 2025

3.34 KB

Similar to an other of my programs, do a bunch of random things about colors and lines. Needs any version of my “nrender” program.


from nrender4 import gradiant,pix,line,circle
from kandinsky import fill_rect as rect,draw_string as txt
from time import sleep,monotonic as m
from ion import keydown as k
from random import randint as r,random,uniform
from math import *
def spectre():
  for i in range(320):
    rect(i,0,1,320,gradiant(i*1530/320))
def grad():
  a=0
  while 1:
    rect(0,0,320,222,gradiant(a))
    a+=1
    sleep(0.05)
def player():
  X,Y=160,111
  a=0
  while 1:
    if k(0)or k(1)or k(2)or k(3)or k(4):
      a+=1
      if k(0)&(X>0):X-=1
      if k(1)&(Y>0):Y-=1
      if k(2)&(Y<213):Y+=1
      if k(3)&(X<311):X+=1
      if k(4):rect(0,0,320,222,(0,)*3)
      pix(X,Y,e=10,g=a)
def rlines():
  while 1:
    if r(0,1):c=-1
    else:c=(r(0,255),r(0,255),r(0,255))
    line(r(-100,400),r(-50,250),r(-100,400),r(-50,250),c,r(1,5),random())
def allsp():
  for i in range(5):
    for j in range(320):
      rect(j,i*44,1,44,gradiant(j+306*i))
def epileptic():
  while 1:
    rect(0,0,320,222,(r(0,255),r(0,255),r(0,255)))
def rlp():
  rect(20,20,20,20,(0,0,255))
  rect(180,180,20,20,(255,0,0))
  for i in range(1,100):
    line(30,30,190,190,-1,2,i/100)
    txt(str(i/100),200,50)
#    sleep(0.05)
    line(30,30,190,190,(0,0,0),2)

def circleold(xc,yc,r,c=(255,)*3,e=1):
  d,d2,d3,d4=c,c,c,c
  for i in range(90):
    if c==-1:
      d=gradiant(i*4.25)
      d2=gradiant(765-(i*4.25))
      d3=gradiant((i*4.25)+765)
      d4=gradiant(1530-(i*4.25))
    ar=radians(i)
    x_inc=int(r*cos(ar))
    y_inc=int(r*sin(ar))
    pix(xc+x_inc,yc+y_inc,d,e)
    pix(xc-x_inc,yc-y_inc,d3,e)
    pix(xc+x_inc,yc-y_inc,d4,e)
    pix(xc-x_inc,yc+y_inc,d2,e)
    sleep(0.001)

def circle_opti(x,y,r=1,c=(255,)*3,e=1,f=False):
  p=2*pi*r
  for i in range(0,360,int(360/p)):
    a=radians(i)
    x_inc=r*cos(a)
    y_inc=r*sin(a)
    pix(round(x+x_inc),round(y+y_inc),c,e)

def loading():
  c=0
  while 1:
    for i in range(360):
      a=radians(i)
      x=160+50*cos(a)
      y=111+50*sin(a)
      circle(int(x),int(y),10,gradiant(c),1,1)
      c+=1
def dvd():
  X,Y=160,111
  x_inc,y_inc=uniform(-1,1),uniform(-1,1)
  c=0
  while 1:
    X+=x_inc
    Y+=y_inc
    if X<=0:
      X=0
      x_inc=random()
      y_inc=-y_inc
    if X>=300:
      X=300
      x_inc=-random()
      y_inc=-y_inc
    if Y<=0:
      Y=0
      y_inc=random()
      x_inc=-x_inc
    if Y>=202:
      Y=202
      y_inc=-random()
      x_inc=-x_inc
    pix(int(X),int(Y),gradiant(c),20)
    c+=1
    sleep(0.001)

def rpixp():
  X,Y,c=160,111,0
  while 1:
    t=r(0,360)
    a=radians(t)
    x_inc=cos(a)
    y_inc=sin(a)
#    print(f"t={t}\na={a}\nx_inc={x_inc}\ny_inc={y_inc}\n")
    X+=x_inc
    Y+=y_inc
#    if 310>=X+x_inc>=0:X+=x_inc
#    if 212>=Y+y_inc>=0:Y+=y_inc
    pix(int(X),int(Y),gradiant(c),10)
    c+=1

def nuke():
  u=0
  for j in range(6):
      for i in range(60):
        a=radians(i+60*j)
        x=160+100*cos(a)
        y=111+100*sin(a)
        if u:c=(255,255,0)
        else:c=(0,0,0)
        line(160,111,int(x),int(y),c,2)
      u=(u+1)%2
  for i in range(10,0,-1):
    circle(160,111,i*2,(0,0,0),2)
  pix(160,111,(0,0,0))

def rcircles():
  while 1:
    circle(r(-50,370),r(-50,272),r(1,100),c=(r(0,255),r(0,255),r(0,255)),e=r(1,5),f=r(0,1))
    while k(4):1

#line(0,0,100,100)
spectre()
#grad()
#epileptic()
#rlines()
#rlp()
#line(0,0,320,222,-1,1,0.3)
#loading()
#dvd()
#rpixp()
#nuke()
#rcircles()
#circle(100,100,100,f=1)

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.