UNPKG

p5.wrapper

Version:

A lightweight declarative wrapper for p5.js that lets you build interactive sketches using Web Components or frameworks like Zikojs, React, VanJS...

31 lines (30 loc) 765 B
import { ZikoP5Shape2D } from "./p5shape2d.js" class ZikoP5Square extends ZikoP5Shape2D{ constructor(x, y, s, tr, tl, br, bl){ super([x, y]) Object.assign(this.cache.geometry,{ s, tr, tl, br, bl }) } __draw_geo__(p){ p.square( ...this.cache.geometry.coordinates, this.cache.geometry.s, this.cache.geometry.tr, this.cache.geometry.tl, this.cache.geometry.br, this.cache.geometry.bl, ); } } const square = (x, y, s, {tr, tl, br, bl} = {}) => new ZikoP5Square(x, y, s, tr, tl, br, bl); const Square = ({x, y, s, tr, tl, br, bl} = {}) => new ZikoP5Square(x, y, s, tr, tl, br, bl); export{ ZikoP5Square, square, Square }