This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@ngx-p5/core
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

@ngx-p5/core

This package provides an easy way to use p5 instance mode, working with classes and CSS selector to attach your sketch. Demo here!

Installation

npm install @ngx-p5/core p5
# or
yarn add @ngx-p5/core p5

Optional, you can install @types/p5

How to use

const sketch = function (p: p5) {  // if you install @types/p5
  /* your awsome sketch */
  p.setup = function() {
    p.createCanvas(200, 400)
    /*  code */
  }

  p.draw = function() {
    p.line(p.width / 2, 0, p.width / 2, 0);
    /* motion and magic here */
  }
}

createCanvas(sketch, '#awsome-sketch');

Optionally you can create a class to manage complexity or integrate with another class base library.

class AwsomeSketch {
    setup(p: any ) { // with typescript 
      /* your setup */
    }
    draw(p) { // with javascript
      /* magic here! */
      p.background(0) // black magic color
    }
}

const sketch = toSketch(new AwsomeSketch());
createCanvas(sketch, '#awsome-sketch');

Example: you can see in action in codepen

Fractals

You can use defaul functionality and ommit second param to attach sketch to body createCanvas(sketch).

Package Sidebar

Install

npm i @ngx-p5/core

Weekly Downloads

4

Version

0.2.1

License

MIT

Unpacked Size

69.5 kB

Total Files

24

Last publish

Collaborators

  • redfox-mx