first_paint.py

Created by mobluse

Created on December 06, 2024

609 Bytes

A paint program. Press the arrow keys to move the painting cursor. Hold down SHIFT to paint faster. Press EXE/Enter to invert the screen. Press BACK/Esc key twice to quit.


# First Paint
from ion import *
from kandinsky import *
import time
def first_paint():
  fill_rect(0,0,320,221,(137,127,117))
  x=160
  y=110
  
  while 1:
    if keydown(KEY_LEFT):
      x-=1
    if keydown(KEY_UP):
      y-=1
    if keydown(KEY_RIGHT):
      x+=1
    if keydown(KEY_DOWN):
      y+=1
    if keydown(KEY_EXE):
      for j in range(221):
        for i in range(320):
          c=get_pixel(i,j)
          set_pixel(i,j,(255-c[0],255-c[1],255-c[2]))
    set_pixel(x,y,(0,255,0))
    if keydown(KEY_SHIFT):
      dt=0.01
    else:
      dt=0.1
    time.sleep(dt)
first_paint()

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.