Skip to content

Instantly share code, notes, and snippets.

@donpark
Created May 6, 2017 01:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donpark/f5e46b6afd1a8b166dc742f012b26a41 to your computer and use it in GitHub Desktop.
Save donpark/f5e46b6afd1a8b166dc742f012b26a41 to your computer and use it in GitHub Desktop.
Setup Paper.js for use in React.js
import * as React from 'react'
import { Component } from 'react'
import { PaperScope } from 'paper'
export class PaperSetup extends Component<any, any> {
constructor(props) {
super(props)
window['paper'] = new PaperScope()
}
render() {
return (
<canvas id="paper" width={0} height={0} />
)
}
componentDidMount() {
let scope = window['paper'] as PaperScope
scope.setup(document.getElementById('#paper') as HTMLCanvasElement)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment