An open API service indexing awesome lists of open source software.

https://github.com/rtlevy/p5-display

A library of controllable React components for p5.js sketches.
https://github.com/rtlevy/p5-display

frontend javascript library p5 react typescript

Last synced: 5 months ago
JSON representation

A library of controllable React components for p5.js sketches.

Awesome Lists containing this project

README

          

A library of controllable React components for p5.js sketches.

# Usage

npm install --save p5-display

p5-display is intended to be used with a bundling tool such as Webpack.
The library is written in Typescript and declaration files are included.

# Example (written in Typescript)

```tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import { P5DisplayStateful, useP5, P5Instance } from "p5-display";

const sketch = (p: P5Instance) => {
let t = 0;

p.setup = () => {
p.createCanvas(500, 500);
}

p.draw = () => {
p.rect(0,0, p.sin(t) * 250 + 250, p.cos(t) * 250 + 250);
t += 0.01;
}

p.reset = () => {
t = 0;
p.clear();
p.draw();
}
}

function Example(props: {}) {
return
}

ReactDOM.render(
, document.getElementById('content-root'));
```

# Building

npm install
npm run build

To build docs, run

npm run docs