Rendering
Canvas.draw_image
Renders the given image onto the canvas.
You can optionally specify a position (
x
,y
, by default both0
) for the top-left corner, as well as a target size (width
,height
, by default equal to the input image's size).An opacity value may also be specified for the composition.
Acceptable types for the input image include:
- A PIL image instance
- A
uint8
NumPy array representing anRGB (h, w, 3)
orRGBA (h, w, 4)
image.
Canvas.from_image
Creates a canvas instance containing the given image.
This is equivalent to creating a canvas with width
and height
matching the image and then calling draw_image
.
Canvas.draw_matrix
Renders a colormapped version of the given matrix (either a NumPy array or a PyTorch tensor) onto the canvas.
The optional target bounds (
x
,y
,width
,height
) andopacity
behave as described in draw_imageThe optional
colormap
keyword argument can be set to one of the values displayed in the IDE.The optional
range
keyword argument can specify the(min, max)
ranges corresponding to the extremes of the colormap. By default, the matrix's min/max values are used.If you just want to display a colormapped version of the matrix with no further changes, consider using the simpler show function.
Canvas.from_matrix
Creates a canvas instance containing a colormapped version of the given matrix.
This is equivalent to creating a canvas with width
and height
matching the matrix and then calling draw_matrix
.