nrender4.py

Created by elnix91

Created on September 28, 2025

771 Bytes

debug version of nrender, the last version is available here


from kandinsky import set_pixel as set,fill_rect as rect
from ion import keydown as k

def pix(x,y,c=(255,)*3,e=1,g=-1):
  if (320>x>0-e)and(222>y>0-e):
    if g!=-1:c=gradiant(g)
    if e==1:set(x,y,c)
    else:rect(x,y,e,e,c)

def line(x0,y0,x1,y1,c=(255,)*3,e=1,p=1):
  dx,dy=x1-x0,y1-y0
  steps=max(abs(dx),abs(dy))
  if steps==0:pix(x0,y0,c,e);return
  xinc,yinc,d,i=dx/steps/p,dy/steps/p,c,0
  while i<steps:
    if c==-1:d=gradiant(i*1530/steps)
    pix(round(x0),round(y0),d,e)
    x0+=xinc
    y0+=yinc
    i+=1/p

def gradiant(n):
#  n%=1530
  n,p,r,g,b=n%1530,n%1530%255,0,0,0
  if n<255:r,b=255,p
  elif n<510:r,b=255-p,255
  elif n<765:g,b=p,255
  elif n<1020:g,b=255,255-p
  elif n<1275:r,g=p,255
  elif n<1530:r,g=255,255-p
  return (r,g,b)

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.