Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/johanbook/react-canvas

React component for drawing particles on a canvas
https://github.com/johanbook/react-canvas

canvas react

Last synced: 21 days ago
JSON representation

React component for drawing particles on a canvas

Awesome Lists containing this project

README

        

# @johanbook/react-canvas

![](https://img.shields.io/travis/johanbook/react-canvas)
![](https://img.shields.io/npm/v/@johanbook/react-canvas)

This library aims to make it easier to draw on HTML canvases.

## Install

Install it using

```sh
npm install @johanbook/react-canvas
```

## Basic usage

We can create a simple wave as

```jsx
import Canvas from "@johanbook/react-canvas";

const NUM = 100;
const items = [];
for(let idx = 0; idx < NUM; idx++){
items.push({x: idx/NUM, y: 0})
}

const handleUpdateItem = (item, t) => {
item.y = Math.sin(item.x*8 +t-0.5)/2 + 0.5;
}

function Component() {
return ();
```