From e72eb471ff0f04a38ab0ee754fac4e0ec376c349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Mon, 21 Mar 2016 15:23:18 +0100 Subject: [PATCH] Tests example: add a new test --- example/src/Tests/ColoredDisc.js | 30 ++++++++++++++++++++++++++++++ example/src/Tests/DiamondCrop.js | 28 ++++++++++++++++++++++++++++ example/src/Tests/index.js | 8 ++++++++ 3 files changed, 66 insertions(+) create mode 100644 example/src/Tests/ColoredDisc.js create mode 100644 example/src/Tests/DiamondCrop.js diff --git a/example/src/Tests/ColoredDisc.js b/example/src/Tests/ColoredDisc.js new file mode 100644 index 0000000..b7f1fe2 --- /dev/null +++ b/example/src/Tests/ColoredDisc.js @@ -0,0 +1,30 @@ +import GL from "gl-react"; +import React from "react"; + +const shaders = GL.Shaders.create({ + ColoredDisc: { + frag: ` +precision highp float; +varying vec2 uv; +uniform vec3 fromColor; +uniform vec3 toColor; +void main () { + float d = 2.0 * distance(uv, vec2(0.5)); + gl_FragColor = mix( + vec4(mix(fromColor, toColor, d), 1.0), + vec4(0.0), + step(1.0, d) + ); +} +` + } +}); + +module.exports = GL.createComponent( + ({ fromColor, toColor }) => + , + { displayName: "ColoredDisc" } +); diff --git a/example/src/Tests/DiamondCrop.js b/example/src/Tests/DiamondCrop.js new file mode 100644 index 0000000..55ceff5 --- /dev/null +++ b/example/src/Tests/DiamondCrop.js @@ -0,0 +1,28 @@ +import GL from "gl-react"; +import React from "react"; + +const shaders = GL.Shaders.create({ + DiamondCrop: { + frag: ` +precision highp float; +varying vec2 uv; +uniform sampler2D t; +void main () { + gl_FragColor = mix( + texture2D(t, uv), + vec4(0.0), + step(0.5, abs(uv.x - 0.5) + abs(uv.y - 0.5)) + ); +} +` + } +}); + +module.exports = GL.createComponent( + ({ children: t }) => + , +{ displayName: "DiamondCrop" } +); diff --git a/example/src/Tests/index.js b/example/src/Tests/index.js index 30eacd8..70db20b 100644 --- a/example/src/Tests/index.js +++ b/example/src/Tests/index.js @@ -13,6 +13,8 @@ import NativeLayer from "./NativeLayer"; import HelloGL from "./HelloGL"; import Display2 from "./Display2"; import Copy from "./Copy"; +import ColoredDisc from "./ColoredDisc"; +import DiamondCrop from "./DiamondCrop"; import TransparentNonPremultiplied from "./TransparentNonPremultiplied"; import Dimensions from "Dimensions"; const { width: viewportW, height: viewportH } = Dimensions.get("window"); @@ -145,6 +147,12 @@ class Tests extends React.Component { + + + http://i.imgur.com/rkiglmm.jpg + + + ; -- 2.26.2