Skip to main content

A small module allowing to link the kandinsky module, from the Numworks, to a window.

Project description

Visitor Badge Downloads pip GitHub Clones

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 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>"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kandinsky-2.6.5.tar.gz (220.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kandinsky-2.6.5-py3-none-any.whl (222.7 kB view details)

Uploaded Python 3

File details

Details for the file kandinsky-2.6.5.tar.gz.

File metadata

  • Download URL: kandinsky-2.6.5.tar.gz
  • Upload date:
  • Size: 220.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for kandinsky-2.6.5.tar.gz
Algorithm Hash digest
SHA256 09ca617ff1d4c9546c440c59a86c924636e1522e298f086bf5bb5370f19667bb
MD5 cc27b91543967180b1634400c729bea9
BLAKE2b-256 25ae4455e9ed21cd54608294ea6998e43c394ac2c2d0d8c6273288959e4be4d0

See more details on using hashes here.

File details

Details for the file kandinsky-2.6.5-py3-none-any.whl.

File metadata

  • Download URL: kandinsky-2.6.5-py3-none-any.whl
  • Upload date:
  • Size: 222.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for kandinsky-2.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6cd5768e17220a69fa8ad92db9a3592573065834a4348dce0e72ae886982aa1c
MD5 e6b1fdb0ffeda106641c0ee7d6d85e4d
BLAKE2b-256 c1f4c53826b57a788faa3c39f744dba74ea21ed2f7c1f4ea9880d76ed0f83da2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page