A small module allowing to link the kandinsky module, from the Numworks, to a window.
Project description
Kandinsky-Numworks
This module depend to PySDL2 module and sdl2 libraries, PySDL2 is just an sdl2 wrapper with ctype and it just call methods in sdl2 library. To install both modules, click here and follow steps.
This module allowing to link the kandinsky module, from the Numworks, to a window. Useful if you want to test your program without putting it on the calculator.
In addition, this module also emulates the drawing speed, and has many other features.
Installation
You now have the option to install this module on pypi.org. For that, follow the steps here.
Or if you want, you can build it yourself, just clone the repo and run the command ./setup
.
More
I also recreated the ion module of the Numworks, check it out here: Ion module of Numworks
If you have a question, check out the FAQ. And if you have a suggestion or your question is not answered, open an Issue.
Usable content
Numworks, aka basic, methods
get_pixel():
- Parameters:
x
,y
- Description: Return pixel (x, y) color
set_pixel():
- Parameters:
x
,y
,color
- Description: Color pixel (x, y)
color():
- Parameters:
r
,g
,b
- Description: Define a rgb color
draw_string():
- Parameters:
text
,x
,y
,color
[default: (0,0,0)],background
[default: (248,252,248)], (Omega & Upsilon only:font
[default: False]) - Description: Display a text from pixel (x, y)
- Note: parameter
font
is only for Omega and Upsilon and it's to chose between small and large font.
fill_rect():
- Parameters:
x
,y
,width
,height
,color
- Description: Fill a rectangle at pixel (x, y)
New method for this library, only on Computer
quit():
- Parameters: No parameters
- Description: Close manualy the window without notifying the user
- Note: after that you cannot reopen the window, so a re-import of kandinsky will be required to get a new window
display():
- Parameters: No parameters
- Description: Refresh manually the window and display changes
- Note: ⚠️Method added only for MacOS, because library cannot refresh automatically the window in another Thread.
It will be necessary to call this method from time to time to keep it alive.⚠️
New methods added by Omega (previous methods are also added)
draw_line()
- Parameters:
x1
,y1
,x2
,y2
,color
- Description: Draw a line at (x1, y1) to (x2, y2)
wait_vblank()
- Parameters: No parameters
- Description: Wait for screen refresh
get_keys()
- Parameters: No parameters
- Description: Get name of pressed keys
New methods added by Upsilon (previous methods are also added except get_keys())
draw_circle()
- Parameters:
x
,y
,r
,color
- Description: Draw circle at (x, y) of radius r
fill_circle()
- Parameters:
x
,y
,r
,color
- Description: Fill circle at (x, y) of radius r
fill_polygon()
- Parameters:
points
,color
- Description: Fill polygon at points [(x1, y1), ...]
get_palette()
- Parameters: No parameters
- Description: Get theme palette
Additional features
A GUI to control emulator
-
Pause/resume: You can pause/resume your script
Note: This will just pause the calls of kandinsky. So for the script to pause, it must be called one of the functions of the library -
Screenshot: You can also take a screenshot of window
Note: This take just the numworks interface and drawable area, not the GUI -
Change OS: Change the speed of execution. You have chose of Numworks, Omega, Upsilon, and PC mode
Note: Only work for kandinsky methods -
Change model: Change the model of numworks. You have chose of n0100, n0110, and the new model n0120
Note: This change the speed python execution emulation of numworks Note2: n0100 and n0120 models are not available for moment. -
Shorcut command: All the features mentioned have a shortcut command. More info in "Help > Shortcuts" menu of window.
Environ options
/!\ You must make its additions before importing kandinsky otherwise the changes will not take effect! /!\
You can also change some default option of library, like the OS or model on which to start kandinsky, etc.
To do this, first import os module and add a compatibility check, like this:
try:
import os
if hasattr(os, "environ"):
"<environ options here>"
except: pass
- Enable debug mode:
os.environ['KANDINSKY_ENABLE_DEBUG'] = ''
- Change starting OS (methods according to the selected os will be created):
# '0': PC speed + all methods
# '1': Numworks speed + Basic methods
# '2': Omega speed + draw_line,wait_vblank,get_keys method
# '3': Upsilon speed + draw_circle,fill_circle,fill_polygon,get_palette methods - get_keys
os.environ['KANDINSKY_OS_MODE'] = '<number>'
- Change starting Model:
# '0': n0100 model speed (not available for moment)
# '1': n0110 model speed
# '2': n0120 model speed (not available for moment)
os.environ['KANDINSKY_MODEL_MODE'] = '<number>'
- Remove the user interface of window (GUI):
# Note: Shortcut commands are not disabled
os.environ['KANDINSKY_NO_GUI'] = ''
- Change size of screen:
os.environ['KANDINSKY_SCREEN_SIZE'] = "<width>x<height>"
- Zoom the window:
# from 1 to 4
os.environ['KANDINSKY_ZOOM_RATIO'] = "<number>"
Experiental features:
- Will try to limit the thread heap to get a better emulation:
# Note: Cannot be enabled on some python versions
os.environ['KANDINSKY_USE_HEAP'] = ''
- Add a button in GUI to allow window resising:
os.environ['KANDINSKY_ENABLE_RESIZING'] = ''
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kandinsky-2.7.2.tar.gz
.
File metadata
- Download URL: kandinsky-2.7.2.tar.gz
- Upload date:
- Size: 217.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c98456292983c555d4da9aa758d595200dbf7dd8dd225381fa6b9ff1d872af03 |
|
MD5 | dae3136284b8c236511c5d7c9058d7c6 |
|
BLAKE2b-256 | 6f2d8c051db4c17ce68578e7194f688e9fbcb76460e81310b4a1f6df39ee336d |
File details
Details for the file kandinsky-2.7.2-py3-none-any.whl
.
File metadata
- Download URL: kandinsky-2.7.2-py3-none-any.whl
- Upload date:
- Size: 219.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86be74cb8f78f9a786fb1f3fa6401144e075b1ba133c9d931c25eab1a778cf96 |
|
MD5 | b9ae2de8afeb203c7a0d52712e3baee3 |
|
BLAKE2b-256 | e64a78677900ed32ebc7a5510ce1640cbf8bf1915d779c3aa6cf4d7cce0e8425 |