Last active
November 18, 2022 20:34
-
-
Save wesleyguirra/54fda5890a73c7385b102cf897138ba9 to your computer and use it in GitHub Desktop.
[Code tutorial] - Building a camera overlay using React-Native
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Dimensions, View, Text } from 'react-native'; | |
import Svg, { Circle, Defs, Rect, Mask } from 'react-native-svg'; | |
const CameraOverlay = () => { | |
const { height, width } = Dimensions.get('window'); | |
const circleRadius = width / 2.5; | |
const viewBox = `0 0 ${width} ${height}` | |
return ( | |
<View aspectRatio={1}> | |
<Svg | |
height={height} | |
viewBox={viewBox} | |
> | |
<Defs> | |
<Mask id="mask"> | |
<Rect height={height} width={width} fill="#fff" /> | |
<Circle r={circleRadius} cx={width / 2} cy={height / 3} fill="#000" /> | |
</Mask> | |
</Defs> | |
<Rect | |
height={height} | |
width={width} | |
fill="#ffffff" | |
mask="url(#mask)" | |
/> | |
</Svg> | |
</View> | |
); | |
}; | |
export default CameraOverlay; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment