Last active
August 8, 2023 09:59
-
-
Save FrontendFocus/5440e0866c3edee8134fc0b79fcce413 to your computer and use it in GitHub Desktop.
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, { useCallback } from "react"; | |
import PropTypes from "prop-types"; | |
import { Path as SvgPath } from "react-native-svg"; | |
import { useRough } from "../hooks"; | |
const RoughPath = ({ onPress,d, ...o }) => { | |
const generator = useRough(o); | |
const paths = generator.toPaths(generator.path(d, o)); | |
return ( | |
<> | |
{paths.map((pathInfo) => ( | |
<SvgPath | |
key={pathInfo.d} | |
d={pathInfo.d} | |
stroke={pathInfo.stroke} | |
strokeWidth={pathInfo.strokeWidth} | |
fill={pathInfo.fill} | |
onPress={onPress} | |
/> | |
))} | |
</> | |
); | |
}; | |
RoughPath.propTypes = { | |
d: PropTypes.string.isRequired, | |
}; | |
RoughPath.defaultProps = {}; | |
export default RoughPath; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment