-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomFilterViewExample01.tsx
More file actions
110 lines (97 loc) · 2.61 KB
/
CustomFilterViewExample01.tsx
File metadata and controls
110 lines (97 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// @ts-ignore
import * as React from 'react';
import { StyleSheet, View, Text, Dimensions } from 'react-native';
import { CustomFilterView } from 'react-native-ios-visual-effect-view';
const WINDOW_SIZE = Dimensions.get('window');
// 1 = black, 0 = transparent
const emojiString =
"❤️🛑🍒🍓💃"
+ "\n🧡🍊🥕🍑🎃"
+ "\n💛🌟🌻🍋🍌"
+ "\n💚🍀🌿🍏🌳"
+ "\n💙🌊🦋🔵💎"
+ "\n💜🍇💐🛸🌌"
+ "\n💖🌸💝🎀💗"
+ "\n🤍✨🌙🦢🦄"
+ "\n🖤🌑🦇🕷️🕸️";
export function CustomFilterViewExample01() {
return (
<View style={styles.container}>
<Text style={styles.label}>
{emojiString}
</Text>
<CustomFilterView
style={styles.effectOverlay}
// increase quality (usually: 0.25...1)
backgroundLayerSamplingSizeScale={1}
// set the filters to use,
// accepts an array of `LayerFilterConfig`
currentFilters={{
backgroundFilters: [
// filter 1 of 4
// create variable blur filter
{
filterName: 'variadicBlur',
radius: 8,
shouldNormalizeEdges: true,
// define the intensity of blur via a gradient
gradientMask: {
type: 'axial',
colors: [
'rgba(0,0,0,1)', // max blur
'rgba(0,0,0,0)', // no blur
],
startPointPreset: 'topCenter',
endPointPreset: 'bottomCenter',
size: {
height: WINDOW_SIZE.height,
width: WINDOW_SIZE.width,
},
}
},
// filter 2 of 4
// Slightly desaturate colors
{
filterName: 'colorBlackAndWhite',
amount: 0.5
},
// filter 3 of 4
// reduce brightness
{
filterName: 'brightenColors',
amount: -0.5
},
// filter 4 of 4
// decrease contrast
{
filterName: 'contrastColors',
amount: 0.4,
},
]
}}
>
<Text>
{'Hello World'}
</Text>
</CustomFilterView>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'white',
},
label: {
fontSize: 72,
},
effectOverlay: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
},
});