1.1.0 • Published 9 months ago

p5-sketch v1.1.0

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

How to use it

Since every class we create in our project needs to be able to use p5 functions, this package solves the problem by exposing the sketch object. So we can import it into any class and use p5 functions as needed.

main.js

import p from 'p5-sketch'
import MyExternalObject from './my-external-object'

let obj

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

p.draw = () => {
  p.background('PapayaWhip')
}

my-external-object.js

import p from 'p5-sketch'

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

  draw() {
    p.noStroke()
    p.fill('blue')
    p.circle(this.x, this.y, 100)
  }
}
1.1.0

9 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago