Skip to content

Instantly share code, notes, and snippets.

@wesleyguirra
Last active November 18, 2022 20:34
Show Gist options
  • Save wesleyguirra/54fda5890a73c7385b102cf897138ba9 to your computer and use it in GitHub Desktop.
Save wesleyguirra/54fda5890a73c7385b102cf897138ba9 to your computer and use it in GitHub Desktop.
[Code tutorial] - Building a camera overlay using React-Native
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