1.0.7 • Published 2 months ago

p5-easy v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

How to use it

To ensure that every class in our project has access to p5 functions, this package resolves the issue by making the 'sketch' object available as a variable named 'p'. This approach allows us to import 'p' into any file and utilize p5 functions as needed.

main.js

import p from 'p5-easy'
import MyObject from './my-object.js'

let obj

p.setup = () => {
  p.createCanvas(600, 600)
  obj = new MyObject()
}

p.draw = () => {
  p.background('black')
  obj.draw()
}

my-object.js

import p from 'p5-easy'

export default class MyObject {
  constructor() {
    this.x = 300
    this.y = 300
  }

  draw() {
    p.circle(this.x, this.y, 100)
  }
}
1.0.7

2 months ago

1.0.6

2 months ago

1.0.5

2 months ago

1.0.2

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.1

5 months ago

1.0.0

6 months ago