33 lines
683 B
CoffeeScript
33 lines
683 B
CoffeeScript
import PropTypes from 'prop-types';
|
|
import * as React from 'react'
|
|
|
|
import {color, Primitives} from '@avocado/graphics'
|
|
import {Rectangle} from '@avocado/math'
|
|
|
|
class PrimitivesComponent extends React.Component
|
|
|
|
constructor: (props) ->
|
|
|
|
super props
|
|
|
|
@primitives = new Primitives()
|
|
|
|
@defaultProps:
|
|
|
|
lineStyle: Primitives.LineStyle color 0, 0, 0
|
|
rectangle: [0, 0, 0, 0]
|
|
|
|
componentWillUnmount: -> @primitives.destroy()
|
|
|
|
render: ->
|
|
|
|
@primitives.clear()
|
|
|
|
unless Rectangle.isNull @props.rectangle
|
|
@primitives.drawRectangle @props.rectangle, @props.lineStyle
|
|
|
|
@props.setIntoContainer @primitives
|
|
return null
|
|
|
|
export default PrimitivesComponent
|