index.ios.js 1.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
const React = require("react-native");
const {
  AppRegistry,
  Text,
  View,
} = React;

const Blur = require("./Blur");
const Add = require("./Add");
const Multiply = require("./Multiply");
const Layer = require("./Layer");
const HelloGL = require("./HelloGL");
const Display2 = require("./Display2");
const { width: viewportW, height: viewportH } = require("Dimensions").get("window");

const Tests = React.createClass({
  render: function() {
    const helloGL =
      <HelloGL width={64} height={64} />;

    const txt =
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
22
      <View style={{ width: 800, height: 800, position: "relative", backgroundColor: "transparent" }}>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
        {[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>;

    const img = "http://i.imgur.com/zJIxPEo.jpg";

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

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

    return <View style={{ backgroundColor: "#000" }}>
      <Display2 width={viewportW} height={viewportH} vertical preload>
        <Display2 width={viewportW} height={viewportH/2}>
          <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}
          </Display2>
        </Display2>
        {txt}
      </Display2>
    </View>;
  }
});

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