import React, {useRef, useState} from 'react'; import {Image, StyleSheet, View} from 'react-native'; import {Circle, G, Line, Path, Rect, Svg} from 'react-native-svg'; const styles = StyleSheet.create({ container: { flex: 1, height: 100, width: 200, }, svg: { flex: 1, alignSelf: 'stretch', }, }); function SvgExample() { return ( ); } SvgExample.title = 'SVG'; function SvgOpacity() { return ( ); } SvgOpacity.title = 'SVG with `opacity` prop'; function SvgViewbox() { return ( ); } SvgViewbox.title = 'SVG with `viewBox="40 20 100 40" and preserveAspectRatio="none"'; function SvgLayout() { return ( ); } SvgLayout.title = 'SVG with flex layout'; function SvgNativeMethods() { const [base64, setBase64] = useState(''); const rootRef = useRef(null); const circleRef = useRef(null); const alert = () => { console.log('PRESSED'); rootRef.current?.toDataURL(data => { setBase64(data); }); console.log(circleRef.current?.isPointInFill({x: 200, y: 100})); console.log(circleRef.current?.isPointInStroke({x: 200, y: 100})); console.log(circleRef.current?.getTotalLength()); console.log(circleRef.current?.getPointAtLength(25)); console.log(circleRef.current?.getBBox({fill: true})); console.log(circleRef.current?.getCTM()); console.log(circleRef.current?.getScreenCTM()); }; return ( <> {base64 && ( )} ); } SvgNativeMethods.title = 'Tap the shapes to render the Image below based on the base64-data of the Svg'; const icon = ( ); const samples = [ SvgExample, SvgOpacity, SvgViewbox, SvgLayout, SvgNativeMethods, ]; export {icon, samples};