import React, {Component} from "react"; import {View, Animated} from "react-native"; import {Surface} from "gl-react-native"; import GL from "gl-react"; const stateForTime = t => ({ colors: [ [ Math.cos(0.002*t), Math.sin(0.002*t), 0.2, 1 ], [ Math.sin(0.002*t), -Math.cos(0.002*t), 0.1, 1 ], [ 0.3, Math.sin(3+0.002*t), Math.cos(1+0.003*t), 1 ] ], particles: [ [ 0.3, 0.3 ], [ 0.7, 0.5 ], [ 0.4, 0.9 ] ] }); export default class AnimatedExample extends Component { state = stateForTime(0); componentWillMount () { const begin = Date.now(); this.interval = setInterval(() => this.setState( stateForTime(Date.now() - begin) )); } componentWillUnmount () { clearInterval(this.interval); } render () { const { colors, particles } = this.state; return 1.0) { sum.rgb /= sum.a; sum.a = 1.0; } gl_FragColor = vec4(sum.a * sum.rgb, 1.0); } ` }} /> ; } }