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
96898fba
Commit
96898fba
authored
Aug 19, 2015
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more examples in simple
parent
9f1b5560
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
236 additions
and
9 deletions
+236
-9
Examples/AdvancedEffects/src/TransitionGenerator.js
Examples/AdvancedEffects/src/TransitionGenerator.js
+1
-1
Examples/Simple/AnimatedHelloGL.js
Examples/Simple/AnimatedHelloGL.js
+47
-0
Examples/Simple/OneFingerResponse.js
Examples/Simple/OneFingerResponse.js
+74
-0
Examples/Simple/PieProgress.js
Examples/Simple/PieProgress.js
+66
-0
Examples/Simple/index.ios.js
Examples/Simple/index.ios.js
+48
-8
No files found.
Examples/AdvancedEffects/src/TransitionGenerator.js
View file @
96898fba
...
@@ -13,7 +13,7 @@ const transitions = [
...
@@ -13,7 +13,7 @@ const transitions = [
}
],
}
],
"
glitch displace
"
,
"
glitch displace
"
,
[
"
Mosaic
"
,
function
()
{
[
"
Mosaic
"
,
function
()
{
cons
t
dx
=
Math
.
round
(
Math
.
random
()
*
6
-
3
),
dy
=
Math
.
round
(
Math
.
random
()
*
6
-
3
);
le
t
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
;
return
{
endx
:
dx
,
endy
:
dy
};
return
{
endx
:
dx
,
endy
:
dy
};
}
],
}
],
...
...
Examples/Simple/AnimatedHelloGL.js
0 → 100644
View file @
96898fba
const
React
=
require
(
"
react-native
"
);
const
GL
=
require
(
"
gl-react-native
"
);
const
shaders
=
GL
.
Shaders
.
create
({
helloGL
:
{
frag
:
`
precision highp float;
varying vec2 uv;
uniform float value;
void main () {
gl_FragColor = vec4(uv.x, uv.y, value, 1.0);
}
`
}
});
class
HelloGL
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
value
:
0
};
}
componentDidMount
()
{
const
loop
=
time
=>
{
requestAnimationFrame
(
loop
);
this
.
setState
({
value
:
(
1
+
Math
.
cos
(
time
/
1000
))
/
2
// cycle between 0 and 1
});
};
requestAnimationFrame
(
loop
);
}
render
()
{
const
{
width
,
height
}
=
this
.
props
;
const
{
value
}
=
this
.
state
;
return
<
GL
.
View
shader
=
{
shaders
.
helloGL
}
width
=
{
width
}
height
=
{
height
}
uniforms
=
{{
value
}}
/>
;
}
}
module
.
exports
=
HelloGL
;
Examples/Simple/OneFingerResponse.js
0 → 100644
View file @
96898fba
const
React
=
require
(
"
react-native
"
);
const
GL
=
require
(
"
gl-react-native
"
);
const
shaders
=
GL
.
Shaders
.
create
({
pieProgress
:
{
frag
:
`
precision mediump float;
varying vec2 uv;
uniform float pressed;
uniform vec2 position;
void main () {
float dist = pow(1.0 - distance(position, uv), 4.0);
float edgeDistX = pow(1.0 - distance(position.x, uv.x), 24.0);
float edgeDistY = pow(1.0 - distance(position.y, uv.y), 24.0);
gl_FragColor = pressed * vec4(0.8 * dist + edgeDistX, 0.7 * dist + edgeDistY, 0.6 * dist, 1.0);
}
`
}
});
class
PieProgress
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
pressed
:
0
,
position
:
[
0
,
0
]
};
this
.
onTouchStart
=
this
.
onTouchStart
.
bind
(
this
);
this
.
onTouchEnd
=
this
.
onTouchEnd
.
bind
(
this
);
this
.
onTouchMove
=
this
.
onTouchMove
.
bind
(
this
);
}
onTouchStart
(
evt
)
{
this
.
setState
({
pressed
:
1
});
this
.
onTouchMove
(
evt
);
}
onTouchMove
(
evt
)
{
const
{
width
,
height
}
=
this
.
props
;
const
{
locationX
,
locationY
}
=
evt
.
nativeEvent
;
this
.
setState
({
position
:
[
Math
.
max
(
0
,
Math
.
min
(
locationX
/
width
,
1
)),
Math
.
max
(
0
,
Math
.
min
(
1
-
locationY
/
height
,
1
))
]
});
}
onTouchEnd
()
{
this
.
setState
({
pressed
:
0
});
}
render
()
{
const
{
width
,
height
}
=
this
.
props
;
const
{
pressed
,
position
}
=
this
.
state
;
return
<
GL
.
View
onStartShouldSetResponderCapture
=
{()
=>
true
}
onMoveShouldSetResponderCapture
=
{()
=>
true
}
onResponderTerminationRequest
=
{()
=>
false
}
onResponderGrant
=
{
this
.
onTouchStart
}
onResponderMove
=
{
this
.
onTouchMove
}
onResponderRelease
=
{
this
.
onTouchEnd
}
onResponderTerminate
=
{
this
.
onTouchEnd
}
width
=
{
width
}
height
=
{
height
}
shader
=
{
shaders
.
pieProgress
}
uniforms
=
{{
pressed
,
position
}}
/>
;
}
}
module
.
exports
=
PieProgress
;
Examples/Simple/PieProgress.js
0 → 100644
View file @
96898fba
const
React
=
require
(
"
react-native
"
);
const
GL
=
require
(
"
gl-react-native
"
);
const
shaders
=
GL
.
Shaders
.
create
({
pieProgress
:
{
frag
:
`
precision mediump float;
varying vec2 uv;
uniform vec4 colorInside, colorOutside;
uniform float radius;
uniform float progress;
uniform vec2 dim;
const vec2 center = vec2(0.5);
const float PI = acos(-1.0);
void main () {
vec2 norm = dim / min(dim.x, dim.y);
vec2 p = uv * norm - (norm-1.0)/2.0;
vec2 delta = p - center;
float inside =
step(length(delta), radius) *
step((PI + atan(delta.y, -delta.x)) / (2.0 * PI), progress);
gl_FragColor = mix(
colorOutside,
colorInside,
inside
);
}
`
}
});
class
PieProgress
extends
React
.
Component
{
render
()
{
const
{
width
,
height
,
progress
,
colorInside
,
colorOutside
,
radius
}
=
this
.
props
;
return
<
GL
.
View
width
=
{
width
}
height
=
{
height
}
shader
=
{
shaders
.
pieProgress
}
opaque
=
{
false
}
uniforms
=
{{
dim
:
[
width
,
height
],
progress
,
colorInside
,
colorOutside
,
radius
}}
/>
;
}
}
PieProgress
.
defaultProps
=
{
colorInside
:
[
0
,
0
,
0
,
0
],
colorOutside
:
[
0
,
0
,
0
,
0.5
],
radius
:
0.4
};
module
.
exports
=
PieProgress
;
Examples/Simple/index.ios.js
View file @
96898fba
...
@@ -13,6 +13,9 @@ const {
...
@@ -13,6 +13,9 @@ const {
const
HelloGL
=
require
(
"
./HelloGL
"
);
const
HelloGL
=
require
(
"
./HelloGL
"
);
const
Saturation
=
require
(
"
./Saturation
"
);
const
Saturation
=
require
(
"
./Saturation
"
);
const
HueRotate
=
require
(
"
./HueRotate
"
);
const
HueRotate
=
require
(
"
./HueRotate
"
);
const
PieProgress
=
require
(
"
./PieProgress
"
);
const
OneFingerResponse
=
require
(
"
./OneFingerResponse
"
);
const
AnimatedHelloGL
=
require
(
"
./AnimatedHelloGL
"
);
class
Simple
extends
React
.
Component
{
class
Simple
extends
React
.
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
...
@@ -20,6 +23,7 @@ class Simple extends React.Component {
...
@@ -20,6 +23,7 @@ class Simple extends React.Component {
this
.
state
=
{
this
.
state
=
{
saturationFactor
:
1
,
saturationFactor
:
1
,
hue
:
0
,
hue
:
0
,
progress
:
0.2
,
text
:
"
and I will return leading the pack
"
text
:
"
and I will return leading the pack
"
};
};
}
}
...
@@ -29,7 +33,8 @@ class Simple extends React.Component {
...
@@ -29,7 +33,8 @@ class Simple extends React.Component {
const
{
const
{
saturationFactor
,
saturationFactor
,
hue
,
hue
,
text
text
,
progress
}
=
this
.
state
;
}
=
this
.
state
;
return
<
ScrollView
style
=
{
styles
.
container
}
>
return
<
ScrollView
style
=
{
styles
.
container
}
>
...
@@ -43,7 +48,7 @@ class Simple extends React.Component {
...
@@ -43,7 +48,7 @@ class Simple extends React.Component {
<
HelloGL
width
=
{
256
}
height
=
{
171
}
/
>
<
HelloGL
width
=
{
256
}
height
=
{
171
}
/
>
<
/View
>
<
/View
>
<
Text
style
=
{
styles
.
demoTitle
}
>
2
.
Saturat
ion
on
an
Image
<
/Text
>
<
Text
style
=
{
styles
.
demoTitle
}
>
2
.
Saturat
e
an
Image
<
/Text
>
<
View
style
=
{
styles
.
demo
}
>
<
View
style
=
{
styles
.
demo
}
>
<
Saturation
<
Saturation
width
=
{
256
}
width
=
{
256
}
...
@@ -52,13 +57,12 @@ class Simple extends React.Component {
...
@@ -52,13 +57,12 @@ class Simple extends React.Component {
image
=
{{
uri
:
"
http://i.imgur.com/iPKTONG.jpg
"
}}
image
=
{{
uri
:
"
http://i.imgur.com/iPKTONG.jpg
"
}}
/
>
/
>
<
SliderIOS
<
SliderIOS
value
=
{
saturationFactor
}
maximumValue
=
{
8
}
maximumValue
=
{
8
}
onValueChange
=
{
saturationFactor
=>
this
.
setState
({
saturationFactor
})}
onValueChange
=
{
saturationFactor
=>
this
.
setState
({
saturationFactor
})}
/
>
/
>
<
/View
>
<
/View
>
<
Text
style
=
{
styles
.
demoTitle
}
>
3
.
Hue
Rotat
ion
on
Text
+
Image
<
/Text
>
<
Text
style
=
{
styles
.
demoTitle
}
>
3
.
Hue
Rotat
e
on
Text
+
Image
<
/Text
>
<
View
style
=
{
styles
.
demo
}
>
<
View
style
=
{
styles
.
demo
}
>
<
HueRotate
<
HueRotate
width
=
{
256
}
width
=
{
256
}
...
@@ -69,7 +73,6 @@ class Simple extends React.Component {
...
@@ -69,7 +73,6 @@ class Simple extends React.Component {
<
Text
style
=
{
styles
.
demoText2
}
>
{
text
}
<
/Text
>
<
Text
style
=
{
styles
.
demoText2
}
>
{
text
}
<
/Text
>
<
/HueRotate
>
<
/HueRotate
>
<
SliderIOS
<
SliderIOS
value
=
{
hue
}
maximumValue
=
{
2
*
Math
.
PI
}
maximumValue
=
{
2
*
Math
.
PI
}
onValueChange
=
{
hue
=>
this
.
setState
({
hue
})}
onValueChange
=
{
hue
=>
this
.
setState
({
hue
})}
/
>
/
>
...
@@ -80,6 +83,34 @@ class Simple extends React.Component {
...
@@ -80,6 +83,34 @@ class Simple extends React.Component {
/
>
/
>
<
/View
>
<
/View
>
<
Text
style
=
{
styles
.
demoTitle
}
>
4
.
Progress
Indicator
<
/Text
>
<
View
style
=
{
styles
.
demo
}
>
<
PieProgress
width
=
{
256
}
height
=
{
180
}
progress
=
{
progress
}
/
>
<
SliderIOS
onValueChange
=
{
progress
=>
this
.
setState
({
progress
})}
/
>
<
/View
>
<
Text
style
=
{
styles
.
demoTitle
}
>
5
.
Touch
Responsive
<
/Text
>
<
View
style
=
{
styles
.
demo
}
>
<
OneFingerResponse
width
=
{
256
}
height
=
{
180
}
/
>
<
/View
>
<
Text
style
=
{
styles
.
demoTitle
}
>
6
.
Animation
<
/Text
>
<
View
style
=
{
styles
.
demo
}
>
<
AnimatedHelloGL
width
=
{
256
}
height
=
{
180
}
/
>
<
/View
>
<
/View
>
<
/View
>
<
/ScrollView>
;
<
/ScrollView>
;
}
}
...
@@ -100,12 +131,21 @@ const styles = StyleSheet.create({
...
@@ -100,12 +131,21 @@ const styles = StyleSheet.create({
demos
:
{
demos
:
{
flex
:
1
,
flex
:
1
,
justifyContent
:
"
center
"
,
justifyContent
:
"
center
"
,
alignItems
:
"
center
"
,
marginLeft
:
40
,
width
:
276
,
marginBottom
:
40
,
},
},
demoTitle
:
{
demoTitle
:
{
marginBottom
:
16
,
fontStyle
:
"
italic
"
,
alignSelf
:
"
flex-start
"
,
color
:
"
#999
"
,
fontWeight
:
"
300
"
,
fontSize
:
20
,
fontSize
:
20
,
margin
:
5
,
},
fontStyle
:
"
italic
"
demo
:
{
marginBottom
:
64
,
marginLeft
:
20
,
},
},
demoText1
:
{
demoText1
:
{
position
:
"
absolute
"
,
position
:
"
absolute
"
,
...
...
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