pixel_studio_advanced_2023.py

Created by wperez274

Created on April 27, 2023

5.92 KB

guide=””” [OK] = Set Shape [pi] = Sketch Mode On/ Off [7]89= “red”, “green, “blue” EXE = Exit & Print Data

Hold [shift] + [(][)][x]/] = Fast Increase, Decrease Width, Height

Length of my_shapes should be ≤ 6 for copy & paste ability. ( Numworks has limit if copy ) Use: from Kandinsky import fill_rect from Kandinsky import fill_rect as F

tuple = color = *white”

bg=(255,255,255) my_shapes =[ [x,y,w,h,c], [x,y,w,h,c],[x,y,w,h,c] ]

for i in my_shapes: F(*i)

Try different keys.. “””


from math import *
from random import *
from random import randint as R
from kandinsky import *
from kandinsky import fill_rect as F

from ion import *
from time import *

guide="""
[OK] = Set Shape
[pi] = Sketch Mode On/ Off
[7]89= "red", "green, "blue"
EXE = Exit & Print Data

Hold [shift] + [(][)][x]/] = Fast Increase, Decrease Width, Height

Length of my_shapes should be ≤ 6 for copy & paste ability.
( Numworks has limit if copy )
Use:
from Kandinsky import fill_rect
from Kandinsky import fill_rect as F

#tuple = color = *white"
bg=(255,255,255)
my_shapes =[
[x,y,w,h,c], [x,y,w,h,c],[x,y,w,h,c]
]

for i in my_shapes:
    F(*i)

Try
different keys..
"""

my_shapes=[]

x=140
y=100
w=20
h=20
c=(0,0,0)

bg= (174, 204, 77)
  
x_y=0
my_pix=[]

my_pix_copy=[]


def clear_screen():
  F(0,0,322,222,bg)

def redraw():

  for i in my_shapes:
    F(*i)
    
  for i in my_pix_copy:
    F(*i)


sketchmode=False



mybgcolors=[]

clear_screen()

while not keydown(KEY_EXE):
  
  F(x,y,w,h,c)
  
  

  if keydown(KEY_LEFT):
    x-=2
    if sketchmode==0:
      F(x+w+1,y-1,2,h+2,bg)
    redraw()
    
  if keydown(KEY_RIGHT):
    x+=2
    if sketchmode==0:
      F(x-2,y-1,2,h+2,bg)
    redraw()




  if keydown(KEY_UP):
    y-=2
    if sketchmode==0:
      F(x-1,y+h+1,w+2,2,bg)
    redraw()

    
    
  if keydown(KEY_DOWN):
    y+=2
    if sketchmode==0:
      F(x-1,y-2,w+2,2,bg)
    redraw()

    
    
    
      
    
    
  if keydown(KEY_OK):
    sleep(0.2)
    my_shapes.append([x,y,w,h,c])
    draw_string("Shapes:"+str(len(my_shapes)),1,1,(0,0,0),(0,255,255))
    draw_string("Shape captured!",140,1)
    sleep(0.5)
    F(0,0,322,20,bg)

    

  if keydown(KEY_VAR):
    sleep(0.2)
    print([x,y])
    x_y+=1
    my_pix.append([x,y])
    my_pix_copy.append([x,y,w,h,(0,0,200)])
    
    draw_string("Pixel:"+str(x_y),1,1)
    draw_string("Pixel[x,y] Captured!",110,1,(0,0,140))
    sleep(0.6)
    F(0,0,322,20,bg)

    
    
    
    
 
  if keydown(KEY_BACKSPACE):
    sleep(0.2)
    if len(my_shapes)>0:
      del my_shapes[-1]
      clear_screen()
      redraw()
      
  
    if my_shapes==[]:
      sleep(0.2)
      if len(my_pix_copy)>0:
        del my_pix_copy[-1]
        clear_screen()
        redraw()
            
      



  if keydown(KEY_POWER):
    sleep(0.2)
    if len(my_pix_copy)>0:
      del my_pix_copy[-1]
      redraw()
        
    

  if keydown(KEY_PI):
    sleep(0.2)
    c=(R(0,255),R(0,255),R(0,255))


    

  if keydown(KEY_SHIFT):
    if keydown(KEY_BACKSPACE):
      sleep(0.2)
      clear_screen()
      my_shapes=[]



  if keydown(KEY_LEFTPARENTHESIS):
    sleep(0.01)
    w-=1
    F(x+w+1,y,1,h,bg)
    if keydown(KEY_SHIFT):
      w-=5
      F(x+w+1,y,5,h,bg)

      
  if keydown(KEY_RIGHTPARENTHESIS):
    sleep(0.01)
    w+=1
    if keydown(KEY_SHIFT):
      w+=5
      


  if keydown(KEY_MULTIPLICATION):
    sleep(0.01)
    h-=1
    F(x,y+h+1,w+1,1,bg)
    if keydown(KEY_SHIFT):
      h-=5
      F(x,y+h+1,w+1,5,bg)


    
  if keydown(KEY_DIVISION):
    sleep(0.01)
    h+=1
    if keydown(KEY_SHIFT):
      h+=5


  if keydown(KEY_IMAGINARY):
    sleep(0.2)
    bg=(R(0,255),R(0,255),R(0,255))
    fill_rect(0,0,322,222,bg)



    
  if w<2:
    w=2
  if h<2:
    h=2



  if x<0:
    x=0
    
    
  if x+w>322:
    x=322-w
    
    
  if y<0:
    y=0
    
    
    
  if y+h>222:
    y=222-h
    
    
  if keydown(KEY_COMMA):
    sleep(0.2)
    bg=(R(0,255),R(0,255),R(0,255))
    clear_screen()
    


  if keydown(KEY_ZERO):
    sleep(0.2)
    w=10
    h=10
    c=(0,255,255)
    clear_screen()
    redraw()


  if keydown(KEY_ONE):
    sleep(0.2)
    w=50
    h=50
    clear_screen()
    redraw()
              
  if keydown(KEY_TWO):
    sleep(0.2)
    w=100
    h=100
    clear_screen()
    redraw()



  if keydown(KEY_DOT):
    sleep(0.2)
    w=322
    h=222
    clear_screen()
    redraw()


  if keydown(KEY_SQRT):
    sleep(0.2)
    w=3
    h=3

    sketchmode+=1

  if sketchmode:
    draw_string("[sketch on]",200,1,(0,)*3,(0,255,255))

    
  if sketchmode>1:
    sketchmode=0
    draw_string("[sketch on]",200,1,bg,bg)


  if keydown(KEY_FOUR):
    sleep(0.2)
    c='yellow'
    
  if keydown(KEY_FIVE):
    sleep(0.2)
    c='purple'
    
  if keydown(KEY_SIX):
    sleep(0.2)
    c='pink'
    





  if keydown(KEY_SEVEN):
    sleep(0.2)
    c='red'

  if keydown(KEY_EIGHT):
    sleep(0.2)
    c='green'
  if keydown(KEY_NINE):
    sleep(0.2)
    c='blue'


    

    
   
    


  if keydown(KEY_TOOLBOX):
    sleep(0.2)
    c=choice([
    'red','green','blue',
    'yellow','brown','purple',
    'pink','orange','gray',
    'black','white','cyan'
    ])



  if keydown(KEY_LOG):
    sleep(0.2)
    bg=choice([
    (155, 217, 243), (152, 234, 229), 
    (37, 83, 72), (255, 13, 213), 
    (52, 190, 37), (110, 252, 242), 
    (77, 39, 30), (233, 243, 13), 
    (104, 154, 96), (174, 223, 163), 
    (77, 118, 246), (90, 102, 98), 
    (154, 231, 93),
    'red','green','blue',
    'yellow','brown','purple',
    'pink','orange','gray',
    'black','white','cyan'
    ])
    clear_screen()
    
    

  if keydown(KEY_TANGENT):
    sleep(0.2)
    mybgcolors.append(bg)
#    print(bg)
    draw_string("bg captured!",100,1)
    sleep(0.5)
    draw_string("bg captured!",100,1,bg,bg)

    

  if keydown(KEY_BACKSPACE):
    if w>12:
      if len(my_shapes)<1:
        sleep(0.2)
        w=12
        h=12
        clear_screen()
    
    if w==322 and h==222:
      x=80
      y=80
      w=100
      h=100
      bg=c
      c=(R(0,255),R(0,255),R(0,255))
      





  if bg==c:
    c=(R(0,255),R(0,255),R(0,255))

    
    


  
mybgcolors=list(set(mybgcolors))  





draw_string("PRESS OK",100,150,(0,)*3,(0,255,255))

print("")
print("-------------------------")
print("mybgcolors=",mybgcolors)
print("-------------------------")
print("bg=",bg)  
print("-------------------------")
print("w,h,c=[",w,",",h,",",c,"]")
print("-------------------------")
print("my_pix=",my_pix)
print("-------------------------")
print("my_shapes=",my_shapes)

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.