-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYinYang.js
85 lines (82 loc) · 1.84 KB
/
YinYang.js
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
import React from 'react';
import {View} from 'react-native';
const YinYang = (props) => {
const styles = yinYangStyles(props.size || 1);
return (
<View style={styles.container}>
<View style={styles.outer}>
<View style={styles.black} />
<View style={styles.white} />
<View style={styles.middle}>
<View style={[styles.middleCommon, styles.middleWhite]}>
<View style={[styles.innerCommon, styles.innerBlack]} />
</View>
<View style={[styles.middleCommon, styles.middleBlack]}>
<View style={[styles.innerCommon, styles.innerWhite]} />
</View>
</View>
</View>
</View>
);
};
const yinYangStyles = (size) => {
return {
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
outer: {
width: size,
height: size,
borderWidth: 1,
borderColor: 'black',
borderRadius: size / 2,
overflow: 'hidden',
},
black: {
flex: 1,
backgroundColor: 'black',
overflow: 'hidden',
},
white: {
flex: 1,
backgroundColor: 'white',
overflow: 'hidden',
},
middle: {
flex: 1,
height: size / 2,
position: 'absolute',
top: size / 4,
left: 0,
right: 0,
flexDirection: 'row',
},
middleCommon: {
width: size / 2,
borderRadius: size / 4,
alignItems: 'center',
justifyContent: 'center',
},
innerCommon: {
width: size / 8,
height: size / 8,
borderRadius: size,
overflow: 'hidden',
},
middleWhite: {
backgroundColor: 'white',
},
innerBlack: {
backgroundColor: 'black',
},
middleBlack: {
backgroundColor: 'black',
},
innerWhite: {
backgroundColor: 'white',
},
};
};
export default YinYang;