index.ios.js 7.67 KB
Newer Older
1 2 3 4 5
const React = require("react-native");
const {
  AppRegistry,
  Text,
  View,
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
6 7
  ScrollView,
  Image,
8 9 10 11 12 13
} = React;

const Blur = require("./Blur");
const Add = require("./Add");
const Multiply = require("./Multiply");
const Layer = require("./Layer");
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
14
const NativeLayer = require("./NativeLayer");
15 16
const HelloGL = require("./HelloGL");
const Display2 = require("./Display2");
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
17
const Copy = require("./Copy");
18
const TransparentNonPremultiplied = require("./TransparentNonPremultiplied");
19 20
const { width: viewportW, height: viewportH } = require("Dimensions").get("window");

21 22 23 24 25 26 27 28 29 30 31 32 33 34
class Tests extends React.Component {

  constructor (props) {
    super(props);
    this.onLoad = this.onLoad.bind(this);
    this.onProgress = this.onProgress.bind(this);
  }
  onLoad () {
    console.log("LOADED");
  }
  onProgress ({nativeEvent: { progress, loaded, total }}) {
    console.log("PROGRESS", progress, loaded, total);
  }
  render () {
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
35 36 37

    const debugSize = viewportW / 2;

38 39 40 41
    const helloGL =
      <HelloGL width={64} height={64} />;

    const txt =
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
42
      <View style={{ width: 800, height: 800, position: "relative", backgroundColor: "transparent" }}>
43 44 45 46 47 48 49 50 51 52 53 54 55 56
        {[0,1,2,3].map(i => <Text style={{
          position: "absolute",
          top: 40+200*i,
          left: 0,
          width: 800,
          height: 200,
          textAlign: "center",
          color: ["#f00", "#0f0", "#00f", "#fff"][i],
          fontSize: 80
        }}>
          Hello World {i}
        </Text>)}
      </View>;

57
    const img = "http://i.imgur.com/zJIxPEo.jpg?t="+Date.now();
58 59 60 61 62 63 64 65 66 67 68 69

    const blurredImage =
      <Blur factor={4} passes={6} width={200} height={200}>
        {img}
      </Blur>;

    const blurredImageOverText =
      <Layer>
        {blurredImage}
        {txt}
      </Layer>;

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83
    return <ScrollView style={{ backgroundColor: "#000" }}>
      <Display2 width={viewportW} height={viewportW} preload onLoad={this.onLoad} onProgress={this.onProgress}>
        <Add width={viewportW/2} height={viewportH/2}>
          {txt}
          {helloGL}
        </Add>
        <Display2 width={viewportW/2} height={viewportH/2} vertical>
          <Blur factor={1} passes={4} width={viewportW/2} height={viewportH/4}>
            <Multiply>
              {blurredImageOverText}
              {helloGL}
            </Multiply>
          </Blur>
          {blurredImage}
84 85
        </Display2>
      </Display2>
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
86 87 88 89 90 91 92 93 94 95


      <View style={{ flexDirection: "row", flexWrap: "wrap" }}>

        <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/mp79p5T.png" }} width={debugSize} height={debugSize} />
        </NativeLayer>

        <NativeLayer width={debugSize} height={debugSize}>
96 97 98
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <Copy width={debugSize} height={debugSize} opaque={false}>
            http://i.imgur.com/mp79p5T.png
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
99 100 101 102 103 104
          </Copy>
        </NativeLayer>

        <NativeLayer width={debugSize} height={debugSize}>
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <Copy width={debugSize} height={debugSize} opaque={false}>
105 106 107
            <Copy>
              http://i.imgur.com/mp79p5T.png
            </Copy>
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
108 109 110 111
          </Copy>
        </NativeLayer>

        <NativeLayer width={debugSize} height={debugSize}>
112 113 114 115 116 117 118
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <Copy width={debugSize} height={debugSize} opaque={false}>
            <Copy>
              <Copy>
                http://i.imgur.com/mp79p5T.png
              </Copy>
            </Copy>
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
119
          </Copy>
120 121 122 123
        </NativeLayer>

        <NativeLayer width={debugSize} height={debugSize}>
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
124
          <Copy width={debugSize} height={debugSize} opaque={false}>
125 126 127 128 129 130 131
            <Copy>
              <Copy>
                <Copy>
                  http://i.imgur.com/mp79p5T.png
                </Copy>
              </Copy>
            </Copy>
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
132 133 134
          </Copy>
        </NativeLayer>

135 136 137 138 139 140 141 142 143 144 145 146 147 148
        <NativeLayer width={debugSize} height={debugSize}>
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <Copy width={debugSize} height={debugSize} opaque={false}>
            <Copy>
              <Copy>
                <Copy>
                  <Copy>
                    http://i.imgur.com/mp79p5T.png
                  </Copy>
                </Copy>
              </Copy>
            </Copy>
          </Copy>
        </NativeLayer>
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213

        <NativeLayer width={debugSize} height={debugSize}>
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <NativeLayer>
            <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
            <TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha>
              <HelloGL />
            </TransparentNonPremultiplied>
          </NativeLayer>
        </NativeLayer>

        <NativeLayer width={debugSize} height={debugSize}>
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <NativeLayer>
            <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
            <TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha>
              <TransparentNonPremultiplied>
                <HelloGL />
              </TransparentNonPremultiplied>
            </TransparentNonPremultiplied>
          </NativeLayer>
        </NativeLayer>

        <NativeLayer width={debugSize} height={debugSize}>
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <NativeLayer>
            <Image source={{ uri: "http://i.imgur.com/mp79p5T.png" }} width={debugSize} height={debugSize} />
            <TransparentNonPremultiplied width={debugSize} height={debugSize} premultipliedAlpha>
              <Copy>
                <TransparentNonPremultiplied>
                  <Copy>
                    http://i.imgur.com/S22HNaU.png
                  </Copy>
                </TransparentNonPremultiplied>
              </Copy>
            </TransparentNonPremultiplied>
          </NativeLayer>
        </NativeLayer>

        <NativeLayer 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>
            http://i.imgur.com/mp79p5T.png
            <TransparentNonPremultiplied>
              <HelloGL />
            </TransparentNonPremultiplied>
          </Layer>
        </NativeLayer>

        <NativeLayer width={debugSize} height={debugSize}>
          <Image source={{ uri: "http://i.imgur.com/S22HNaU.png" }} width={debugSize} height={debugSize} />
          <Layer width={debugSize} height={debugSize} opaque={false}>
            http://i.imgur.com/mp79p5T.png
            <TransparentNonPremultiplied>
              <Copy>
                <TransparentNonPremultiplied>
                  <Copy>
                    http://i.imgur.com/S22HNaU.png
                  </Copy>
                </TransparentNonPremultiplied>
              </Copy>
            </TransparentNonPremultiplied>
          </Layer>
        </NativeLayer>

Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
214 215 216
      </View>

    </ScrollView>;
217
  }
218
}
219 220

AppRegistry.registerComponent("Tests", () => Tests);