Created
March 5, 2020 14:05
-
-
Save vojto/f9680802b62833e01bb849a3570c46c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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