🖼️ Image preloads for web are now available. Get your images faster! See draw_image for more details.

Sketchingpy

Creative coding and interactive science everywhere for everyone: web, desktop, mobile, Jupyter, and more. Open source!

Reference for draw_image

Draw an image at a location. This is part of the reference section.

Purpose

Draw a previously loaded image at a specific coordinate using its current size.

Snippet

Draw reference.png at x coordinate of 100 and y coordinate of 200.
image = sketch.get_image('reference.png')
sketch.draw_image(100, 200, image)

Parameters

  • x: Horizontal coordinate at which to draw the image.
  • y: Vertical coordinate at which to draw the image.
  • image: The image to draw.

Examples

Availability

Available for all platforms. On web, this will search for an img tag with id "preload-img-" followed by the filename where spaces and periods are replaced with dashes. If found, it will use that image instead of loading it again. This prevents a delay in the image becoming available and reduces network traffic.

See also