Overview
scripton.canvas
provides a powerful and efficient immediate mode raster graphics API. You can use it for drawing 2D scenes in realtime directly from Python.
The first step is to create a Canvas
instance. You can think of it as the image being drawn on.
The dimensions (
width
andheight
) need to be specified at the time of creation. The units are inpixels
.The default background color for the canvas is transparent (allowing you to create images with alpha channels). However, you can also specify a background color during creation:
canvas = Canvas( width=300, height=200, fill='white' )
Once you've created a canvas, you can start drawing using one of the many available primitives. For example:
Coordinates
The coordinate system for the canvas has its origin (0, 0)
at the top left corner, with x
increasing to the right and y
increasing downwards —
Learn More
- How to draw shapes like rectangles and circles
- How to draw straight and curved paths
- How to specify colors
- How to create color gradients