Skip to main content

Helper Class for Using p5.js with PyScript.

Project description

P5Canvas Helper Class

概要

P5Canvasはp5.jsをPyScript(ブラウザ上で動くPython)で使うためのヘルパーライブラリです。

使い方

import P5Canvas

class MyCanvas(P5Canvas):
    def setup(self, p5):
        self.x = 100
        self.y = 100
        p5.createCanvas(300, 300)

    def draw(self, p5):
        p5.background(128)
        p5.fill(255, 0, 0)
        p5.ellipse(self.x, self.y, 50, 50)

        if p5.keyIsDown(p5.LEFT_ARROW):
            self.x -= 1
        if p5.keyIsDown(p5.RIGHT_ARROW):
            self.x += 1
        if p5.keyIsDown(p5.UP_ARROW):
            self.y -= 1
        if p5.keyIsDown(p5.DOWN_ARROW):
            self.y += 1

MyCanvas().run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

p5canvas-1.0.0.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

P5Canvas-1.0.0-py3-none-any.whl (2.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page