Commit 7c3157ba authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

Migrate examples to 2.0.0

parent 21fbd017
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
}, },
"dependencies": { "dependencies": {
"gl-react-native": "file:../..", "gl-react-native": "file:../..",
"gl-react-core": "file:../../../gl-react-core",
"glsl-transitions": "^2015.11.8", "glsl-transitions": "^2015.11.8",
"react-native": "^0.14.2" "react-native": "^0.14.2"
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-core");
const GL = require("gl-react-native"); const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
banner: { banner: {
frag: ` frag: `
...@@ -27,13 +27,9 @@ void main( void ) { ...@@ -27,13 +27,9 @@ void main( void ) {
class Banner extends React.Component { class Banner extends React.Component {
render () { render () {
const { width, height, time } = this.props; const { width, height, time } = this.props;
return <GL.View return <Surface width={width} height={height} opaque={false}>
shader={shaders.banner} <GL.Node shader={shaders.banner} uniforms={{ time: time }} />
width={width} </Surface>;
height={height}
uniforms={{ time: time }}
opaque={false}
/>;
} }
} }
......
...@@ -3,8 +3,8 @@ const { ...@@ -3,8 +3,8 @@ const {
View, View,
Text, Text,
} = React; } = React;
const GL = require("gl-react-core");
const GL = require("gl-react-native"); const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
drunkEffect: { drunkEffect: {
...@@ -40,11 +40,9 @@ void main() { ...@@ -40,11 +40,9 @@ void main() {
class Intro extends React.Component { class Intro extends React.Component {
render () { render () {
const { time, fps, width, height } = this.props; const { time, fps, width, height } = this.props;
return <GL.View return <Surface width={width} height={height} opaque={false}>
<GL.Node
shader={shaders.drunkEffect} shader={shaders.drunkEffect}
width={width}
height={height}
opaque={false}
uniforms={{ uniforms={{
time: time, time: time,
freq: 20 - 14 * Math.sin(time / 7), freq: 20 - 14 * Math.sin(time / 7),
...@@ -71,7 +69,8 @@ class Intro extends React.Component { ...@@ -71,7 +69,8 @@ class Intro extends React.Component {
</View> </View>
</View> </View>
</GL.Uniform> </GL.Uniform>
</GL.View>; </GL.Node>
</Surface>;
} }
} }
......
const React = require("react-native"); const React = require("react-native");
const { View, Text, StyleSheet } = React; const { View, Text, StyleSheet } = React;
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const TransitionGenerator = require("./TransitionGenerator"); const TransitionGenerator = require("./TransitionGenerator");
const Transition = require("./Transition"); const Transition = require("./Transition");
...@@ -33,15 +34,15 @@ class Slideshow extends React.Component { ...@@ -33,15 +34,15 @@ class Slideshow extends React.Component {
const transitionUniforms = this._uniforms; const transitionUniforms = this._uniforms;
return <View style={styles.root}> return <View style={styles.root}>
<Surface width={width} height={height}>
<Transition <Transition
width={width}
height={height}
progress={transitionProgress} progress={transitionProgress}
from={transitionFrom} from={transitionFrom}
to={transitionTo} to={transitionTo}
shader={transitionShader} shader={transitionShader}
uniforms={transitionUniforms} uniforms={transitionUniforms}
/> />
</Surface>
<View style={styles.legend}> <View style={styles.legend}>
<Text style={styles.textName}>{transitionName}</Text> <Text style={styles.textName}>{transitionName}</Text>
<Text style={styles.textInfo}>(GLSL.io)</Text> <Text style={styles.textInfo}>(GLSL.io)</Text>
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, shader, progress, from, to, uniforms }) => { ({ width, height, shader, progress, from, to, uniforms }) => {
const scale = React.PixelRatio.get(); const scale = React.PixelRatio.get();
return <GL.View return <GL.Node
preload preload
shader={shader} shader={shader}
width={width} width={width}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
imageVignette: { imageVignette: {
...@@ -55,15 +56,16 @@ class Vignette extends React.Component { ...@@ -55,15 +56,16 @@ class Vignette extends React.Component {
render () { render () {
const { width, height, time, source } = this.props; const { width, height, time, source } = this.props;
const { finger } = this.state; const { finger } = this.state;
return <GL.View return <Surface
width={width}
height={height}
opaque={false}
preload preload
onStartShouldSetResponder={() => true} onStartShouldSetResponder={() => true}
onMoveShouldSetResponder={() => true} onMoveShouldSetResponder={() => true}
onResponderMove={this.onResponderMove} onResponderMove={this.onResponderMove}>
<GL.Node
shader={shaders.imageVignette} shader={shaders.imageVignette}
width={width}
height={height}
opaque={false}
uniforms={{ uniforms={{
time: time, time: time,
freq: 10 + 2 * Math.sin(0.7*time), freq: 10 + 2 * Math.sin(0.7*time),
...@@ -72,7 +74,8 @@ class Vignette extends React.Component { ...@@ -72,7 +74,8 @@ class Vignette extends React.Component {
moving: 0, moving: 0,
finger: finger finger: finger
}} }}
/>; />
</Surface>;
} }
} }
......
require("gl-react-core/react-native");
const React = require("react-native"); const React = require("react-native");
const { const {
StyleSheet, StyleSheet,
...@@ -61,6 +62,7 @@ class AdvancedEffects extends React.Component { ...@@ -61,6 +62,7 @@ class AdvancedEffects extends React.Component {
width={viewportW} width={viewportW}
height={introH} height={introH}
/> />
<Vignette <Vignette
time={time} time={time}
width={imgW} width={imgW}
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
}, },
"dependencies": { "dependencies": {
"gl-react-native": "file:../..", "gl-react-native": "file:../..",
"gl-react-core": "file:../../../gl-react-core",
"react-native": "^0.14.2", "react-native": "^0.14.2",
"react-native-material-kit": "^0.2.2" "react-native-material-kit": "^0.2.2"
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
helloGL: { helloGL: {
...@@ -38,12 +39,12 @@ class HelloGL extends React.Component { ...@@ -38,12 +39,12 @@ class HelloGL extends React.Component {
render () { render () {
const { width, height } = this.props; const { width, height } = this.props;
const { value } = this.state; const { value } = this.state;
return <GL.View return <Surface width={width} height={height}>
<GL.Node
shader={shaders.helloGL} shader={shaders.helloGL}
width={width}
height={height}
uniforms={{ value }} uniforms={{ value }}
/>; />
</Surface>;
} }
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const Blur1D = require("./Blur1D"); const Blur1D = require("./Blur1D");
module.exports = GL.createComponent(({ width, height, factor, children }) => module.exports = GL.createComponent(({ width, height, factor, children }) =>
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
blur1D: { blur1D: {
...@@ -35,7 +35,7 @@ void main () { ...@@ -35,7 +35,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, direction, children }) => ({ width, height, direction, children }) =>
<GL.View <GL.Node
shader={shaders.blur1D} shader={shaders.blur1D}
width={width} width={width}
height={height} height={height}
...@@ -44,7 +44,7 @@ module.exports = GL.createComponent( ...@@ -44,7 +44,7 @@ module.exports = GL.createComponent(
resolution: [ width, height ] resolution: [ width, height ]
}}> }}>
<GL.Uniform name="t">{children}</GL.Uniform> <GL.Uniform name="t">{children}</GL.Uniform>
</GL.View> </GL.Node>
, { , {
displayName: "Blur1D" displayName: "Blur1D"
}); });
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
helloGL: { helloGL: {
...@@ -14,11 +14,7 @@ void main () { // This function is called FOR EACH PIXEL ...@@ -14,11 +14,7 @@ void main () { // This function is called FOR EACH PIXEL
} }
}); });
module.exports = GL.createComponent(({ width, height }) => module.exports = GL.createComponent(() =>
<GL.View <GL.Node shader={shaders.helloGL} />,
shader={shaders.helloGL}
width={width}
height={height}
/>,
{ displayName: "HelloGL" } { displayName: "HelloGL" }
); );
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
hueRotate: { hueRotate: {
...@@ -26,10 +26,10 @@ void main() { ...@@ -26,10 +26,10 @@ void main() {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ hue, children, ...rest }) => ({ hue, children, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
shader={shaders.hueRotate} shader={shaders.hueRotate}
uniforms={{ hue }}> uniforms={{ hue }}>
<GL.Uniform name="tex">{children}</GL.Uniform> <GL.Uniform name="tex">{children}</GL.Uniform>
</GL.View> </GL.Node>
, { displayName: "HueRotate" }); , { displayName: "HueRotate" });
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const {Surface} = require("gl-react-native");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
oneFingerResponse: { oneFingerResponse: {
...@@ -55,7 +56,7 @@ class OneFingerResponse extends React.Component { ...@@ -55,7 +56,7 @@ class OneFingerResponse extends React.Component {
render () { render () {
const { width, height } = this.props; const { width, height } = this.props;
const { pressed, position } = this.state; const { pressed, position } = this.state;
return <GL.View return <Surface
onStartShouldSetResponderCapture={() => true} onStartShouldSetResponderCapture={() => true}
onMoveShouldSetResponderCapture={() => true} onMoveShouldSetResponderCapture={() => true}
onResponderTerminationRequest={() => false} onResponderTerminationRequest={() => false}
...@@ -64,10 +65,12 @@ class OneFingerResponse extends React.Component { ...@@ -64,10 +65,12 @@ class OneFingerResponse extends React.Component {
onResponderRelease={this.onTouchEnd} onResponderRelease={this.onTouchEnd}
onResponderTerminate={this.onTouchEnd} onResponderTerminate={this.onTouchEnd}
width={width} width={width}
height={height} height={height}>
<GL.Node
shader={shaders.oneFingerResponse} shader={shaders.oneFingerResponse}
uniforms={{ pressed, position }} uniforms={{ pressed, position }}
/>; />
</Surface>;
} }
} }
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
pieProgress: { pieProgress: {
...@@ -41,11 +41,8 @@ module.exports = GL.createComponent( ...@@ -41,11 +41,8 @@ module.exports = GL.createComponent(
colorOutside, colorOutside,
radius radius
}) => }) =>
<GL.View <GL.Node
width={width}
height={height}
shader={shaders.pieProgress} shader={shaders.pieProgress}
opaque={false}
uniforms={{ uniforms={{
dim: [ width, height ], dim: [ width, height ],
progress, progress,
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
saturation: { saturation: {
...@@ -21,7 +21,7 @@ void main () { ...@@ -21,7 +21,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ factor, image, ...rest }) => ({ factor, image, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
shader={shaders.saturation} shader={shaders.saturation}
uniforms={{ factor, image }} uniforms={{ factor, image }}
......
require("gl-react-core/react-native");
const React = require("react-native"); const React = require("react-native");
const { const {
StyleSheet, StyleSheet,
...@@ -8,6 +10,8 @@ const { ...@@ -8,6 +10,8 @@ const {
Component, Component,
} = React; } = React;
const { Surface } = require("gl-react-native");
const { const {
mdl: { mdl: {
Progress, Progress,
...@@ -109,7 +113,9 @@ class Simple extends Component { ...@@ -109,7 +113,9 @@ class Simple extends Component {
<Demos onChange={current => this.setState({ current })} value={current}> <Demos onChange={current => this.setState({ current })} value={current}>
<Demo title="1. Hello GL"> <Demo title="1. Hello GL">
<HelloGL width={256} height={171} ref="helloGL" /> <Surface width={256} height={171} ref="helloGL">
<HelloGL />
</Surface>
<View style={{ paddingTop: 20, alignItems: "center", flexDirection: "row" }}> <View style={{ paddingTop: 20, alignItems: "center", flexDirection: "row" }}>
<Button onPress={this.onCapture1}>captureFrame()</Button> <Button onPress={this.onCapture1}>captureFrame()</Button>
{captured && <Image source={{ uri:captured }} style={{ marginLeft: 20, width: 51, height: 34 }} />} {captured && <Image source={{ uri:captured }} style={{ marginLeft: 20, width: 51, height: 34 }} />}
...@@ -117,12 +123,12 @@ class Simple extends Component { ...@@ -117,12 +123,12 @@ class Simple extends Component {
</Demo> </Demo>
<Demo title="2. Saturate an Image"> <Demo title="2. Saturate an Image">
<Surface width={256} height={171}>
<Saturation <Saturation
width={256}
height={171}
factor={saturationFactor} factor={saturationFactor}
image={{ uri: "http://i.imgur.com/iPKTONG.jpg" }} image={{ uri: "http://i.imgur.com/iPKTONG.jpg" }}
/> />
</Surface>
<Slider <Slider
max={8} max={8}
onChange={saturationFactor => this.setState({ saturationFactor })} onChange={saturationFactor => this.setState({ saturationFactor })}
...@@ -130,15 +136,13 @@ class Simple extends Component { ...@@ -130,15 +136,13 @@ class Simple extends Component {
</Demo> </Demo>
<Demo id={3} current={current} title="3. Hue Rotate on Text+Image"> <Demo id={3} current={current} title="3. Hue Rotate on Text+Image">
<HueRotate <Surface autoRedraw width={256} height={180}>
autoRedraw <HueRotate hue={hue}>
width={256}
height={180}
hue={hue}>
<Image style={{ width: 256, height: 244 }} source={{ uri: "http://i.imgur.com/qVxHrkY.jpg" }}/> <Image style={{ width: 256, height: 244 }} source={{ uri: "http://i.imgur.com/qVxHrkY.jpg" }}/>
<Text style={styles.demoText1}>Throw me to the wolves</Text> <Text style={styles.demoText1}>Throw me to the wolves</Text>
<Text style={styles.demoText2}>{text}</Text> <Text style={styles.demoText2}>{text}</Text>
</HueRotate> </HueRotate>
</Surface>
<Slider <Slider
max={2 * Math.PI} max={2 * Math.PI}
onChange={hue => this.setState({ hue })} onChange={hue => this.setState({ hue })}
...@@ -161,11 +165,9 @@ class Simple extends Component { ...@@ -161,11 +165,9 @@ class Simple extends Component {
}} }}
source={{ uri: "http://i.imgur.com/qM9BHCy.jpg" }}/> source={{ uri: "http://i.imgur.com/qM9BHCy.jpg" }}/>
<View style={{ position: "absolute", top: 0, left: 0 }}> <View style={{ position: "absolute", top: 0, left: 0 }}>
<PieProgress <Surface width={256} height={180} opaque={false}>
width={256} <PieProgress progress={progress} width={256} height={180} />
height={180} </Surface>
progress={progress}
/>
</View> </View>
</View> </View>
<Slider <Slider
...@@ -189,22 +191,24 @@ class Simple extends Component { ...@@ -189,22 +191,24 @@ class Simple extends Component {
</Demo> </Demo>
<Demo id={7} current={current} title="7. Blur (2-pass)"> <Demo id={7} current={current} title="7. Blur (2-pass)">
<Blur preload width={256} height={180} factor={factor + 1}> <Surface preload width={256} height={180}>
<Blur width={256} height={180} factor={factor + 1}>
http://i.imgur.com/3On9QEu.jpg http://i.imgur.com/3On9QEu.jpg
</Blur> </Blur>
</Surface>
<Slider <Slider
max={2} max={2}
onChange={factor => this.setState({ factor })} /> onChange={factor => this.setState({ factor })} />
</Demo> </Demo>
<Demo id={8} current={current} title="8. Blur+Hue over UI"> <Demo id={8} current={current} title="8. Blur+Hue over UI">
<HueRotate <Surface
hue={-switch1 + 2 * switch2 + 4 * switch3}
width={256} width={256}
height={160} height={160}
autoRedraw autoRedraw
eventsThrough eventsThrough
visibleContent> visibleContent>
<HueRotate hue={-switch1 + 2 * switch2 + 4 * switch3}>
<Blur <Blur
width={256} width={256}
height={160} height={160}
...@@ -230,6 +234,7 @@ class Simple extends Component { ...@@ -230,6 +234,7 @@ class Simple extends Component {
</Blur> </Blur>
</Blur> </Blur>
</HueRotate> </HueRotate>
</Surface>
</Demo> </Demo>
<Demo id={9} current={current} title="9. Texture from array"> <Demo id={9} current={current} title="9. Texture from array">
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
}, },
"dependencies": { "dependencies": {
"gl-react-native": "file:../..", "gl-react-native": "file:../..",
"react-native": "^0.15.0" "gl-react-core": "file:../../../gl-react-core",
"react-native": "^0.14.2"
}, },
"devDependencies": { "devDependencies": {
"react-native-cli": "^0.1.7" "react-native-cli": "^0.1.7"
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
add: { add: {
...@@ -23,7 +23,7 @@ module.exports = GL.createComponent( ...@@ -23,7 +23,7 @@ module.exports = GL.createComponent(
({ width, height, children }) => { ({ width, height, children }) => {
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Add"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Add");
const [t1, t2] = children; const [t1, t2] = children;
return <GL.View return <GL.Node
shader={shaders.add} shader={shaders.add}
width={width} width={width}
height={height} height={height}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const { const {
PropTypes PropTypes
} = React; } = React;
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const { const {
PropTypes PropTypes
...@@ -34,7 +34,7 @@ void main () { ...@@ -34,7 +34,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, direction, children }) => ({ width, height, direction, children }) =>
<GL.View <GL.Node
shader={shaders.blur1D} shader={shaders.blur1D}
width={width} width={width}
height={height} height={height}
...@@ -43,7 +43,7 @@ module.exports = GL.createComponent( ...@@ -43,7 +43,7 @@ module.exports = GL.createComponent(
resolution: [ width, height ] resolution: [ width, height ]
}}> }}>
<GL.Uniform name="t">{children}</GL.Uniform> <GL.Uniform name="t">{children}</GL.Uniform>
</GL.View> </GL.Node>
, { , {
displayName: "Blur1D" displayName: "Blur1D"
}); });
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
Copy: { Copy: {
...@@ -23,7 +23,7 @@ void main () { ...@@ -23,7 +23,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height, children: t, last, ...rest }) => ({ width, height, children: t, last, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
shader={shaders.Copy} shader={shaders.Copy}
width={width} width={width}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
display2: { display2: {
...@@ -27,7 +27,7 @@ module.exports = GL.createComponent( ...@@ -27,7 +27,7 @@ module.exports = GL.createComponent(
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Display2"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Display2");
let [t1, t2] = children; let [t1, t2] = children;
if (vertical) [t1,t2]=[t2,t1]; // just because webgl y's is reversed if (vertical) [t1,t2]=[t2,t1]; // just because webgl y's is reversed
return <GL.View return <GL.Node
{...rest} {...rest}
shader={shaders.display2} shader={shaders.display2}
width={width} width={width}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
helloGL: { helloGL: {
...@@ -16,7 +16,7 @@ void main () { // This function is called FOR EACH PIXEL ...@@ -16,7 +16,7 @@ void main () { // This function is called FOR EACH PIXEL
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ width, height }) => ({ width, height }) =>
<GL.View <GL.Node
shader={shaders.helloGL} shader={shaders.helloGL}
width={width} width={width}
height={height} height={height}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
layer: { layer: {
...@@ -23,7 +23,7 @@ module.exports = GL.createComponent( ...@@ -23,7 +23,7 @@ module.exports = GL.createComponent(
({ children, ...rest }) => { ({ children, ...rest }) => {
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Layer"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Layer");
const [t1, t2] = children; const [t1, t2] = children;
return <GL.View return <GL.Node
{...rest} {...rest}
shader={shaders.layer} shader={shaders.layer}
uniforms={{ t1, t2 }} uniforms={{ t1, t2 }}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
multiply: { multiply: {
...@@ -23,7 +23,7 @@ module.exports = GL.createComponent( ...@@ -23,7 +23,7 @@ module.exports = GL.createComponent(
({ width, height, children }) => { ({ width, height, children }) => {
if (!children || children.length !== 2) throw new Error("You must provide 2 children to Multiply"); if (!children || children.length !== 2) throw new Error("You must provide 2 children to Multiply");
const [t1, t2] = children; const [t1, t2] = children;
return <GL.View return <GL.Node
shader={shaders.multiply} shader={shaders.multiply}
width={width} width={width}
height={height} height={height}
......
const React = require("react-native"); const React = require("react-native");
const GL = require("gl-react-native"); const GL = require("gl-react-core");
const shaders = GL.Shaders.create({ const shaders = GL.Shaders.create({
TransparentNonPremultiplied: { TransparentNonPremultiplied: {
...@@ -18,7 +18,7 @@ void main () { ...@@ -18,7 +18,7 @@ void main () {
module.exports = GL.createComponent( module.exports = GL.createComponent(
({ children: t, ...rest }) => ({ children: t, ...rest }) =>
<GL.View <GL.Node
{...rest} {...rest}
opaque={false} opaque={false}
shader={shaders.TransparentNonPremultiplied} shader={shaders.TransparentNonPremultiplied}
......
require("gl-react-core/react-native");
const React = require("react-native"); const React = require("react-native");
const { const {
AppRegistry,
Text, Text,
View, View,
ScrollView, ScrollView,
Image, Image,
} = React; } = React;
const { Surface } = require("gl-react-native");
const Blur = require("./Blur"); const Blur = require("./Blur");
const Add = require("./Add"); const Add = require("./Add");
const Multiply = require("./Multiply"); const Multiply = require("./Multiply");
...@@ -54,7 +54,7 @@ class Tests extends React.Component { ...@@ -54,7 +54,7 @@ class Tests extends React.Component {
</Text>)} </Text>)}
</View>; </View>;
const img = "http://i.imgur.com/zJIxPEo.jpg?t="+Date.now(); const img = "http://i.imgur.com/zJIxPEo.jpg";
const blurredImage = const blurredImage =
<Blur factor={4} passes={6} width={200} height={200}> <Blur factor={4} passes={6} width={200} height={200}>
...@@ -68,7 +68,8 @@ class Tests extends React.Component { ...@@ -68,7 +68,8 @@ class Tests extends React.Component {
</Layer>; </Layer>;
return <ScrollView style={{ backgroundColor: "#000" }}> return <ScrollView style={{ backgroundColor: "#000" }}>
<Display2 width={viewportW} height={viewportW} preload onLoad={this.onLoad} onProgress={this.onProgress}> <Surface width={viewportW} height={viewportW} preload onLoad={this.onLoad} onProgress={this.onProgress}>
<Display2>
<Add width={viewportW/2} height={viewportH/2}> <Add width={viewportW/2} height={viewportH/2}>
{txt} {txt}
{helloGL} {helloGL}
...@@ -83,7 +84,7 @@ class Tests extends React.Component { ...@@ -83,7 +84,7 @@ class Tests extends React.Component {
{blurredImage} {blurredImage}
</Display2> </Display2>
</Display2> </Display2>
</Surface>
<View style={{ flexDirection: "row", flexWrap: "wrap" }}> <View style={{ flexDirection: "row", flexWrap: "wrap" }}>
...@@ -94,34 +95,41 @@ class Tests extends React.Component { ...@@ -94,34 +95,41 @@ class Tests extends React.Component {
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy last>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
</Copy> </Copy>
</Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy last>
<Copy> <Copy>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
</Copy> </Copy>
</Copy> </Copy>
</Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy last>
<Copy> <Copy>
<Copy> <Copy>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Copy>
</Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false} last> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy last>
<Copy> <Copy>
<Copy> <Copy>
<Copy> <Copy>
...@@ -130,13 +138,15 @@ class Tests extends React.Component { ...@@ -130,13 +138,15 @@ class Tests extends React.Component {
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Copy>
</Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Copy width={debugSize} height={debugSize} opaque={false}> <Surface width={debugSize} height={debugSize} opaque={false}>
<Copy last> <Copy last>
<Copy> <Copy>
<Copy>
<Copy> <Copy>
<Copy> <Copy>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
...@@ -145,15 +155,18 @@ class Tests extends React.Component { ...@@ -145,15 +155,18 @@ class Tests extends React.Component {
</Copy> </Copy>
</Copy> </Copy>
</Copy> </Copy>
</Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<NativeLayer> <NativeLayer>
<Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
<TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha> <Surface width={debugSize} height={debugSize}>
<TransparentNonPremultiplied>
<HelloGL /> <HelloGL />
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</Surface>
</NativeLayer> </NativeLayer>
</NativeLayer> </NativeLayer>
...@@ -161,11 +174,13 @@ class Tests extends React.Component { ...@@ -161,11 +174,13 @@ class Tests extends React.Component {
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<NativeLayer> <NativeLayer>
<Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
<TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha> <Surface width={debugSize} height={debugSize}>
<TransparentNonPremultiplied>
<TransparentNonPremultiplied> <TransparentNonPremultiplied>
<HelloGL /> <HelloGL />
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</Surface>
</NativeLayer> </NativeLayer>
</NativeLayer> </NativeLayer>
...@@ -173,7 +188,8 @@ class Tests extends React.Component { ...@@ -173,7 +188,8 @@ class Tests extends React.Component {
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<NativeLayer> <NativeLayer>
<Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
<TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha> <Surface width={debugSize} height={debugSize}>
<TransparentNonPremultiplied>
<Copy> <Copy>
<TransparentNonPremultiplied> <TransparentNonPremultiplied>
<Copy> <Copy>
...@@ -182,22 +198,26 @@ class Tests extends React.Component { ...@@ -182,22 +198,26 @@ class Tests extends React.Component {
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</Copy> </Copy>
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</Surface>
</NativeLayer> </NativeLayer>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Layer width={debugSize} height={debugSize} opaque={false} premultipliedAlpha debug> <Surface width={debugSize} height={debugSize} opaque={false}>
<Layer>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
<TransparentNonPremultiplied> <TransparentNonPremultiplied>
<HelloGL /> <HelloGL />
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</Layer> </Layer>
</Surface>
</NativeLayer> </NativeLayer>
<NativeLayer width={debugSize} height={debugSize}> <NativeLayer width={debugSize} height={debugSize}>
<Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} /> <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
<Layer width={debugSize} height={debugSize} opaque={false}> <Surface width={debugSize} height={debugSize} opaque={false}>
<Layer>
http://i.imgur.com/mp79p5T.png http://i.imgur.com/mp79p5T.png
<TransparentNonPremultiplied> <TransparentNonPremultiplied>
<Copy> <Copy>
...@@ -209,6 +229,7 @@ class Tests extends React.Component { ...@@ -209,6 +229,7 @@ class Tests extends React.Component {
</Copy> </Copy>
</TransparentNonPremultiplied> </TransparentNonPremultiplied>
</Layer> </Layer>
</Surface>
</NativeLayer> </NativeLayer>
</View> </View>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment