Package: sketching
Sketching.pyGroupBadgesStatusUsageDocumentationTiny tools for creative coding and interactive science in Python. Supporting portability acrossdesktop,web,mobile,Jupyter notebooks, andstatic images. Serving makers of all kinds from experienced designers and developers to educators and students. Includes tools for geospatial visualization.Learn more athttps://sketchingpy.org.QuickstartA first sketch in 7 lines of code (edit and run this first sketch in your browser):import sketching

sketch = sketching.Sketch2D(500, 500)

sketch.clear('#F0F0F0')
sketch.set_fill('#C0C0C0')
sketch.set_stroke('#000000')
sketch.draw_ellipse(250, 250, 20, 20)

sketch.show()A tiny bit of example interactivity in just over 10 lines (edit and run this little drawing program in your browser):import sketching

sketch = sketching.Sketch2D(500, 500)

def draw():
  mouse = sketch.get_mouse()
  
  x = mouse.get_x()
  y = mouse.get_y()
  
  sketch.set_fill('#C0C0C0')
  sketch.set_stroke('#333333')
  sketch.draw_ellipse(x, y, 20, 20)

sketch.on_step(draw)

sketch.clear('#FFFFFF')

sketch.show()InstallThere's multiple ways to use Sketching.py with different dependencies for different platforms. It will try to operate with what is installed, turning off different functionality when libraries are not available. Note that sketching in the browser will operate as a pure-Python wheel without additional requirements.Online sketchbookNo installation needed! Just get your browser and start quickly using an online private sketchbook (coming soon but a slimmed down editor is available athttps://sketchingpy.org/examples/web/example.html).Plain Python: static sketchesWrite Python scripts like you usually do and run them from the command line or your IDE. Just grab a few minimal dependencies:$ pip install sketching[static]Note that this will use theSketch2DStaticrenderer by default. Learn more aboutusing sketches inside standard Python programs.Plain Python: interactive sketchesFor interactive sketches, also install pygame in addition to the static dependencies:$ pip install sketching[desktop]Note that this will use theSketch2DApprenderer by default. Learn more aboutusing sketches inside standard Python programs.Jupyter NotebookCode creatively in Jupyter notebooks with minimal dependencies:$ pip install sketching[notebook]Go deeper and review thegetting started instructions for Jupyter.Custom web applicationsEmbed Sketching.py in your own websites. Simply add this to yourpyscriptpy-config:"packages": ["sketching"]Review documentation aboutwriting sketches for the browseror addingSketching.py into your own web pages. Note that no additional dependencies are needed and sketching will install as a pure-Python wheel for maximum compatibility. Numpy, matplotlib, etc are not required.UseMore educational resources coming soon. Seeexamplesandreferencefor now. After you've made something you want to share,take your creations to the webor export your work tostand-alone executables.PurposeThis interactive coding tool enables anyone to start creative coding in minutes using Python across multiple platforms including desktop and web. Heavily inspired byProcessing, Sketching.py seeks to bring the philosophy of sketching in code to portable technologies that allow programmers to take their work anywhere. We believe coding should be iterative, fun, and creative at any stage of someone's journey.GoalsSpecifically, this project seeks to:Enable creative expression in computation through Python.Be simple to use, friendly for everyone from beginners to experts.Support Mac, Windows, Linux, the browser, Jupyter, and static image generation in headless environments.Work in plain old 100% Python with Sketching.py available as a library, supporting you anywhere in your programming journey.We hope to reach developers of all skill levels.Use casesWe imagine folks using Sketching.py for:Interactive scienceData visualizationVisual artImmersive experienceSimulationSound designUser experience (UX) prototypingGame developmentWe would love to see what you do and invite contributions toour showcase.AudienceWe aim to support teachers, students, artists, designers, developers, and other makers as they make creative programs including visual art, games needing a bit more flexibility, and more. Specifically, this project hopes to embrace a wide group of people:Serve programmers no matter where they are in their journey from beginner to expert.Support portabilty across desktop (Mac, Windows, Linux), web (browser), notebooks (Jupyter), and static image generation.Foster inclusive community across different disciplines within and outside computer science.Assist in both formal and informal educational contexts.If you are interested in this mission, we invite a diverse set of collaborators to join us.ScopeCurrently we are only focused on 2D with no explicit console support though Steam Deck should work with the Linux builds.Grow Sketching.pyThank you for your interest in our humble project. Here is how to build Sketching itself and how to participate in our community including contributing code to the project.Environment setupThe recommended packages for development can be installed with the following:$ pip install .[dev]Note that this assumespypi and Python3are installed.TestingThere are multiple layers of tests to ensure code quality and stability:Standard unit tests: Executable with$ nose2, this will execute unit tests which do not require actual instantiation of a renderer.Static tests: Execution of most static Pillow-based examples to ensure no errors are generated using the Docker image inci-image.App tests: Execution of most Pygame-baed examples to ensure no errors are generated using the Docker image inci-imageand xvfb.Web tests: Execution of select web-based examples to ensure no errors are generated using the Docker image inci-imageand Selenium. The number of examples is kept low due to resource intensiveness of this stage.Please ensure all tests pass before merging.Development standardsPlease adhere to the following when contributing code to the project:Precedent is most important: please follow the conventions you see in the repository already.Where there isn't precedent, please use theGoogle Python Style Guidewhere possible.All private members should be prefaced with a single underscore.All public members should have Google-style docstrings.All public members should have type hints.Across these different options, the project aims for 90% code coverage.Getters and setters preferred overThe above represent our ambitions as a project. Please do not let those stop you from opening pull requests if you are not sure how to contribute. We will work with you! Note that we also have formalized some exceptions to those guidelines:Type hints are encouraged but not required for "renderer-native" types.Type hints and docstrings not required for test code.Guidelines encouraged but not required for "support" scripts that are not installed with the library itself.Guidelines encouraged but not required for examples. Authors should determine when the guidelines either improve or hinder readability.Code should pass pyflakes (pyflakes sketching/*.py) and pycodestyle (pycodestyle sketching/*.py) should both pass. Furthermore, please ensure mypy succeeds before opening a PR (mypy sketching/*.py).ReleasePlease release using CI / CD where possible which is done automatically when merging to themainbranch. However, if manual deployment is required:pip install build twine
python3 -m build
twine check dist/*
python3 support/make_twine_config.py
twine upload --config-file ./pypirc dist/*Seesupport/make_twine_config.pyfor additional details.Get involvedSketching hopes to foster an inclusive community of makers.Let us know about a bug or other issue.Contribute to the code of Sketching.py itself.Help with documentation.Share your work in our showcase.Also,join us in our Discord to share ideas!Open SourceSketching both uses open source and is released under a permissive license.Libraries usedWe use and thank the following open source libraries:Ace Editorunder theBSD Licensefor the web editor.bezierunder theApache v2 License.Pillowunder theHPND LicenseforSketch2DandSketch2DStaticrenderers.processing-geopointunder theBSD License.Pygameunder theLGPL LicenseforSketch2Drenderer.Pyscriptunder theApache v2 Licensefor theSketch2DWebrenderer.Pyodideunder theMPL 2.0 Licensefor theSketch2DWebrenderer.Other code and contributors listed in the code itself or withinthe people section of the website. Some documentation usesIBM Plex Monounder theOFL 1.0. Also, some examples colors fromColorBrewer 2.0.LicenseSketching.py is permissivelyBSD licensedmeaning you can use it for commerical and non-commerical projects as well as for your hobbies and for your professional work.