Hugo H ab164256df
All checks were successful
FTP Upload on Push / deploy (push) Successful in 8s
FTP Upload on Push / release (push) Successful in 7s
Added code sharing into editor
2025-12-26 19:00:34 +00:00
2025-11-28 18:25:14 +00:00
2025-12-26 19:00:34 +00:00
2025-12-26 15:17:06 +00:00

PyCanvas

PyCanvas is a Skulpt library for creating 2D games. It is based on litecanvas, and uses the HTML Canvas API. The demo editor is available at PyStudio and provides a nice online editor for writing code.

Usage

To use PyCanvas, you can add the following to the top of your skulpt builtInRead() function:

if (x === 'screen' || x === './screen.js') {
    const url = new URL('screen.js', window.location.href).href;
    const xhr = new XMLHttpRequest();
    xhr.open("GET", url, false);
    xhr.send();
    if (xhr.status === 200) return xhr.responseText;
    else throw "Could not load screen.js";
}

And set these variables before running the code:

const canvas = document.getElementById('canvas');
const container = document.getElementById('preview-container');
if (canvas && container) {
    const w = Math.floor(container.clientWidth);
    const h = Math.floor(container.clientHeight);
    canvas.width = w;
    canvas.height = h;
}

Then you can use it in your code like this:

import screen as s

def draw():
    s.cls(0)
    s.text(20, 20, "Hello World!", 3)

s.start({
    "loop":{
        "draw":draw
    }
})
Description
PyCanvas is a Skulpt library for creating 2D games.
https://pystudio.haaxman.co.uk
Readme 133 KiB
prod Latest
2025-12-26 16:04:02 +00:00
Languages
HTML 61.5%
JavaScript 32%
PHP 6.5%