Skip to content

Instantly share code, notes, and snippets.

@FrontendFocus
Last active August 8, 2023 09:59
Show Gist options
  • Save FrontendFocus/5440e0866c3edee8134fc0b79fcce413 to your computer and use it in GitHub Desktop.
Save FrontendFocus/5440e0866c3edee8134fc0b79fcce413 to your computer and use it in GitHub Desktop.
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