Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gl-react-native-v2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
gl-react-native-v2
Commits
233b7a57
Commit
233b7a57
authored
Aug 17, 2015
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better demo
parent
77367906
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
57 deletions
+49
-57
Examples/AdvancedEffects/src/Slideshow.js
Examples/AdvancedEffects/src/Slideshow.js
+44
-37
Examples/AdvancedEffects/src/TransitionGenerator.js
Examples/AdvancedEffects/src/TransitionGenerator.js
+3
-19
Examples/AdvancedEffects/src/index.js
Examples/AdvancedEffects/src/index.js
+2
-1
No files found.
Examples/AdvancedEffects/src/Slideshow.js
View file @
233b7a57
const
React
=
require
(
"
react-native
"
);
const
React
=
require
(
"
react-native
"
);
const
{
View
,
Text
,
StyleSheet
}
=
React
;
const
GL
=
require
(
"
gl-react-native
"
);
const
GL
=
require
(
"
gl-react-native
"
);
const
TransitionGenerator
=
require
(
"
./TransitionGenerator
"
);
const
TransitionGenerator
=
require
(
"
./TransitionGenerator
"
);
const
Transition
=
require
(
"
./Transition
"
);
const
Transition
=
require
(
"
./Transition
"
);
...
@@ -11,9 +12,10 @@ class Slideshow extends React.Component {
...
@@ -11,9 +12,10 @@ class Slideshow extends React.Component {
this
.
_currentTransition
=
-
1
;
this
.
_currentTransition
=
-
1
;
}
}
render
()
{
render
()
{
const
{
duration
,
width
,
height
,
time
,
images
}
=
this
.
props
;
const
{
transitionDuration
,
pauseDuration
,
width
,
height
,
time
,
images
}
=
this
.
props
;
const
duration
=
transitionDuration
+
pauseDuration
;
const
slide
=
time
/
duration
;
const
slide
=
time
/
duration
;
let
transitionProgress
=
slide
%
1
;
let
transitionProgress
=
Math
.
min
(
1
,
(
duration
/
transitionDuration
)
*
(
slide
%
1
))
;
let
transitionFrom
=
images
[
Math
.
floor
(
slide
)
%
images
.
length
];
let
transitionFrom
=
images
[
Math
.
floor
(
slide
)
%
images
.
length
];
let
transitionTo
=
images
[
Math
.
floor
(
slide
+
1
)
%
images
.
length
];
let
transitionTo
=
images
[
Math
.
floor
(
slide
+
1
)
%
images
.
length
];
...
@@ -21,40 +23,18 @@ class Slideshow extends React.Component {
...
@@ -21,40 +23,18 @@ class Slideshow extends React.Component {
if
(
currentTransition
!==
this
.
_currentTransition
)
{
if
(
currentTransition
!==
this
.
_currentTransition
)
{
this
.
_currentTransition
=
currentTransition
;
this
.
_currentTransition
=
currentTransition
;
const
{
name
,
uniforms
}
=
TransitionGenerator
.
random
();
const
{
name
,
uniforms
}
=
TransitionGenerator
.
random
();
console
.
log
(
name
);
this
.
_name
=
name
;
this
.
_shader
=
shaders
[
name
];
this
.
_shader
=
shaders
[
name
];
this
.
_uniforms
=
uniforms
;
this
.
_uniforms
=
uniforms
;
}
}
const
transitionName
=
this
.
_name
;
const
transitionShader
=
this
.
_shader
;
const
transitionShader
=
this
.
_shader
;
const
transitionUniforms
=
this
.
_uniforms
;
const
transitionUniforms
=
this
.
_uniforms
;
/*
return
<
View
style
=
{
styles
.
root
}
>
switch (Math.floor(slide/4) % 3) {
<
Transition
case 0:
transitionShader = shaders.transitionRandomSquares;
const w = 3 * (1 + Math.floor(slide % 8));
transitionUniforms = {
size: [w, w * 2 / 3],
smoothness: 0.5
};
break;
case 1:
transitionShader = shaders.transitionDirectionalWipe;
transitionUniforms = {
direction: [Math.cos(time/2), Math.sin(time/2)],
smoothness: 0.5
};
break;
case 2:
transitionShader = shaders.transitionWind;
transitionUniforms = {
size: 0.2
};
break;
}
*/
return
<
Transition
width
=
{
width
}
width
=
{
width
}
height
=
{
height
}
height
=
{
height
}
progress
=
{
transitionProgress
}
progress
=
{
transitionProgress
}
...
@@ -62,8 +42,35 @@ class Slideshow extends React.Component {
...
@@ -62,8 +42,35 @@ class Slideshow extends React.Component {
to
=
{
transitionTo
}
to
=
{
transitionTo
}
shader
=
{
transitionShader
}
shader
=
{
transitionShader
}
uniforms
=
{
transitionUniforms
}
uniforms
=
{
transitionUniforms
}
/>
;
/
>
<
View
style
=
{
styles
.
legend
}
>
<
Text
style
=
{
styles
.
textName
}
>
{
transitionName
}
<
/Text
>
<
Text
style
=
{
styles
.
textInfo
}
>
(
GLSL
.
io
)
<
/Text
>
<
/View
>
<
/View>
;
}
}
}
}
const
styles
=
StyleSheet
.
create
({
root
:
{
position
:
"
relative
"
},
legend
:
{
position
:
"
absolute
"
,
bottom
:
5
,
right
:
4
,
backgroundColor
:
"
transparent
"
,
flexDirection
:
"
row
"
},
textName
:
{
color
:
"
#fff
"
,
fontWeight
:
"
bold
"
,
},
textInfo
:
{
color
:
"
#fff
"
,
marginLeft
:
8
,
opacity
:
0.5
}
});
module
.
exports
=
Slideshow
;
module
.
exports
=
Slideshow
;
Examples/AdvancedEffects/src/TransitionGenerator.js
View file @
233b7a57
...
@@ -12,8 +12,6 @@ const transitions = [
...
@@ -12,8 +12,6 @@ const transitions = [
return
{
strength
:
0.5
*
Math
.
random
()
};
return
{
strength
:
0.5
*
Math
.
random
()
};
}
],
}
],
"
glitch displace
"
,
"
glitch displace
"
,
"
crosshatch
"
,
"
PageCurl
"
,
[
"
Mosaic
"
,
function
()
{
[
"
Mosaic
"
,
function
()
{
const
dx
=
Math
.
round
(
Math
.
random
()
*
6
-
3
),
dy
=
Math
.
round
(
Math
.
random
()
*
6
-
3
);
const
dx
=
Math
.
round
(
Math
.
random
()
*
6
-
3
),
dy
=
Math
.
round
(
Math
.
random
()
*
6
-
3
);
if
(
dx
===
0
&&
dy
===
0
)
dy
=
-
1
;
if
(
dx
===
0
&&
dy
===
0
)
dy
=
-
1
;
...
@@ -38,23 +36,12 @@ const transitions = [
...
@@ -38,23 +36,12 @@ const transitions = [
}
],
}
],
"
Star Wipe
"
,
"
Star Wipe
"
,
"
pinwheel
"
,
"
pinwheel
"
,
[
"
Slide
"
,
function
()
{
const
choices
=
[
{
translateX
:
0
,
translateY
:
-
1
},
{
translateX
:
0
,
translateY
:
1
},
{
translateX
:
-
1
,
translateY
:
0
},
{
translateX
:
1
,
translateY
:
0
}
];
return
choices
[
Math
.
floor
(
choices
.
length
*
Math
.
random
())];
}
],
"
SimpleFlip
"
,
"
SimpleFlip
"
,
"
TilesScanline
"
,
"
TilesScanline
"
,
"
Dreamy
"
,
"
Dreamy
"
,
"
Swirl
"
,
"
Swirl
"
,
"
HSVfade
"
,
"
HSVfade
"
,
[
"
burn
"
,
function
()
{
"
burn
"
,
return
{
color
:
[
0
,
0
,
0
].
map
(
Math
.
random
)
};
}
],
"
Radial
"
,
"
Radial
"
,
[
"
ripple
"
,
function
()
{
[
"
ripple
"
,
function
()
{
return
{
return
{
...
@@ -74,7 +61,7 @@ const transitions = [
...
@@ -74,7 +61,7 @@ const transitions = [
return
{
flashIntensity
:
4
*
Math
.
random
()
};
return
{
flashIntensity
:
4
*
Math
.
random
()
};
}
],
}
],
[
"
randomsquares
"
,
function
()
{
[
"
randomsquares
"
,
function
()
{
const
size
=
Math
.
round
(
4
+
3
0
*
Math
.
random
());
const
size
=
Math
.
round
(
4
+
2
0
*
Math
.
random
());
return
{
return
{
size
:
[
size
,
size
],
size
:
[
size
,
size
],
smoothness
:
Math
.
random
()
smoothness
:
Math
.
random
()
...
@@ -96,10 +83,7 @@ const transitions = [
...
@@ -96,10 +83,7 @@ const transitions = [
}
],
}
],
"
circleopen
"
,
"
circleopen
"
,
[
"
wind
"
,
function
()
{
[
"
wind
"
,
function
()
{
return
{
size
:
0.5
*
Math
.
random
()
};
return
{
size
:
0.1
+
0.2
*
Math
.
random
()
};
}
],
[
"
fadecolor
"
,
function
()
{
return
{
color
:
[
0
,
0
,
0
].
map
(
Math
.
random
)
};
}
]
}
]
].
map
(
function
(
obj
)
{
].
map
(
function
(
obj
)
{
let
name
,
genUniforms
;
let
name
,
genUniforms
;
...
...
Examples/AdvancedEffects/src/index.js
View file @
233b7a57
...
@@ -81,7 +81,8 @@ class AdvancedEffects extends React.Component {
...
@@ -81,7 +81,8 @@ class AdvancedEffects extends React.Component {
width
=
{
viewportW
}
width
=
{
viewportW
}
height
=
{
transitionH
}
height
=
{
transitionH
}
images
=
{
images
.
slice
(
2
)}
images
=
{
images
.
slice
(
2
)}
duration
=
{
3
}
pauseDuration
=
{
0.5
}
transitionDuration
=
{
1.5
}
/
>
/
>
<
/View
>
<
/View
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment