Skip to content

Enable to use PVector outside setup and draw #158

@berinhard

Description

@berinhard

The PRs #137 and #135 (thanks @villares <3) introduced support to a PVector class to be closer to Processing's API. But a PVector can't be initialized outside setup or draw yet. Probably we'll have to introduce some lazy loading in the __init__ to enable this.

Here's a sample code to reproduce the bug:

v = PVector(50, 50)

def setup():
    size(400, 400)
    background(160)

def draw():
    translate(50, 200)
    fill("blue")
    background(200)
    radius = sin(frameCount / 60) * 50 + 50
    ellipse(v.x, v.y, radius, radius)

Transcypt traceback

Uncaught TypeError: _P5_INSTANCE is null
    PVector pyp5js.py:978
    <anonymous> vec.py:3

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions