How to use the p5 function in p5

To help you get started, we’ve selected a few p5 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github piratefsh / p5js-art / app / index.js View on Github external
p.translate(0, height-50);
        // stroke(random(100,200),random(100,200),0)

        for(let i = 0; i < systems.length; i++){
            const options = systems[i];
            options.p = p;
            console.log(options)
            const l = new LSystem(options);
            p.translate(distanceX, 0)
            l.run(iterations[i]);
        }
    }
}

// set global functions for p5
const p5Instance = new p5(sketch)
github ml5js / ml5-library / examples / es6 / lstm / src / index.js View on Github external
This is a port of Daniel Shiffman Nature of Code: Intelligence and Learning
Original Repo: https://github.com/shiffman/NOC-S17-2-Intelligence-Learning

Cristóbal Valenzuela
https://github.com/cvalenzuela/p5deeplearn
===
*/

import p5 from 'p5';
import 'p5/lib/addons/p5.dom';
import { lstm } from './lstm';

let textInput, tempSlider, lengthSlider, maxlen = 40,
  waiting = false;

let sketch = new p5((p) => {

  p.setup = () => {
    p.noCanvas();

    // Grab the DOM elements
    textInput = p.select('#textInput');
    lengthSlider = p.select('#lenSlider');
    tempSlider = p.select('#tempSlider');

    // Run generate anytime something changes
    textInput.input(generate);
    lengthSlider.input(generate);
    tempSlider.input(generate);
  };

  let generate = () => {
github luan007 / libao / p5-helper.js View on Github external
export function p5Init(domParent) {
    var myp5 = new p5(() => {}, domParent);
    myp5.setup = () => {
        console.warn("Warning, please override p5 setup function");
    };
    return myp5;
}
github youphonic / youphonic / src / components / P5Wrapper.js View on Github external
componentDidMount() {
    this.canvas = new p5(this.props.sketch, this.wrapper);
    this.canvas.myCustomRedrawAccordingToNewPropsHandler(this.props);
    ourP5 = this.canvas;
    rectangleSeed()
  }
github ccorcos / circle / src / blah.js View on Github external
reload() {
    this.p.remove();
    new p5(this.sketch, this.root);
  }
  deriveSizes() {
github LiamPKenna / js-drumz / src / js / synth.js View on Github external
const runSynth = () => {

  const p5 = new P5();
  let carrier;
  let modulator;
  let analyzer;
  let modFreq;
  let modDepth;


  const radius = 200;
  let modMaxFreq = 100;
  let modMinFreq = 80;
  let modMaxDepth = 100;
  let modMinDepth = -100;



  const setup = () => {
github stc / HackPact / Day-09-Freefall / src / index.js View on Github external
ptick1 = tick1;
	}

  p.keyPressed = () => {
    if(p.key == 'm') {
      p.save(Date.now() + ".jpg");
    }
  }
  p.mousePressed = () => {
    StartAudioContext(Tone.context).then(function(){});
  }
}

export default sketch;
new p5(sketch);
github stc / HackPact / Day-10-Flow-Field / src / index.js View on Github external
vehicles2[i].run();
    }
  }

  p.keyPressed = () => {
    if(p.key == 'm') {
      p.save(Date.now() + ".jpg");
    }
  }
  p.mousePressed = () => {
    StartAudioContext(Tone.context).then(function(){});
  }
}

export default sketch;
new p5(sketch);
github ml5js / ml5-library / examples / es6 / mnist / src / index.js View on Github external
This is a port of Daniel Shiffman Nature of Code: Intelligence and Learning
Original Repo: https://github.com/shiffman/NOC-S17-2-Intelligence-Learning

Cristóbal Valenzuela
https://github.com/cvalenzuela/p5deeplearn
===
*/

import p5 from 'p5';
import 'p5/lib/addons/p5.dom';
import { predict } from './predict';

let result, submit, drawing = false,
  next = false;

let sketch = new p5((p) => {

  p.setup = () => {
    let canvas = p.createCanvas(200, 200);
    p.pixelDensity(1);
    canvas.mousePressed(startDrawing);
    canvas.mouseReleased(stopDrawing);
    result = p.createP(' ');
    submit = p.createButton('classify');
    submit.mousePressed(classify);
    p.background(0);
  };

  p.draw = () => {
    if (drawing) {
      p.stroke(245);
      p.strokeWeight(20);

p5

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

LGPL-2.1
Latest version published 5 days ago

Package Health Score

95 / 100
Full package analysis