Skip to content

Instantly share code, notes, and snippets.

@vojto
Created March 5, 2020 14:05
Show Gist options
  • Save vojto/f9680802b62833e01bb849a3570c46c5 to your computer and use it in GitHub Desktop.
Save vojto/f9680802b62833e01bb849a3570c46c5 to your computer and use it in GitHub Desktop.
import { Graphics } from 'pixi.js';
import { PixiComponent, Stage } from '@inlet/react-pixi';
const Rectangle = PixiComponent('Rectangle', {
create: props => new Graphics(),
applyProps: (instance, _, props) => {
const { x, y, width, height, fill, alpha } = props;
instance.clear();
instance.beginFill(fill);
instance.drawRect(x, y, width, height);
instance.endFill();
instance.alpha = alpha;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment