

Cross-platform React Native drawing component based on SVG
source link: https://reactnativeexample.com/cross-platform-react-native-drawing-component-based-on-svg/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

@benjeau/react-native-draw
Cross-platform React Native drawing component based on SVG.

Example application with React Native performance overlay
Installation
npm install @benjeau/react-native-draw
# or
yarn add @benjeau/react-native-draw
Also, you need to install react-native-gesture-handler, @react-native-community/slider and react-native-svg, and follow their installation instructions.
Usage
import React from 'react';
import { Draw, DrawRef } from "@benjeau/react-native-draw";
export default function App() {
const drawRef = useRef<DrawRef>(null);
const removeLastPath = () {
drawRef.current.?undo();
}
const clearDrawing = () {
drawRef.current.?clear();
}
// ... for more ref functions, look below
return (
<Draw
ref={drawRef}
initialThickness={20}
initialOpacity={0.5}
initialDrawing ={[]}
canvasContainerStyle={{ elevation: 0, backgroundColor: "red" }}
/>
)
}
Props
None of the following props are required
name
description
type
default
colors
Color palette colors, specifying the color palette sections each containing rows of colors
string[][][]
DEFAULT_COLORS
initialThickness
Initial thickness of the brush strokes
number
3
initialOpacity
Initial opacity of the brush strokes
number
1
initialDrawing
Paths to be already drawn
PathType[]
[]
canvasContainerStyle
Override the style of the container of the canvas
StyleProp
onPathsChange
Callback function when paths change
(paths: PathType
[]) => any
name
description
type
undo
Undo last brush stroke
() => void
clear
Removes all brush strokes
() => void
getPaths
Get brush strokes data
() => PathType[]
addPath
Append a path to the current drawing paths
(path: PathType) => void
GitHub
SVG based React Native drawing component — Read More
Recommend
-
31
Tabs A cross-platform Collapsible Tab View component for React Native Dec 03, 2020...
-
8
Tabs Smooth and fast cross platform Material Design Tabs for React Native Paper Dec...
-
47
Search A cross-platform selector/picker component for React Native May 07, 2021...
-
12
react-native-fast-toast Toast component for React Native, supports Android, IOS and Web Features Fully Customizable Swipe to close support Smooth animation Fully typed with TypeScr...
-
2
react-native-shadow-2 Cross-platform shadow for React Native. Improved version of the abandoned react-native-shadow package. react-native-shadow is dead for years. This one is an improved version with more functionalities, Typ...
-
8
Caching Cross-platform support for easy disk caching in React Native Jul 30, 2021...
-
7
react-native-ridge-navigation Simple and performant cross platform navigation on iOS, Android and the web with simple and type-safe api for React 18 (alpha) ⚠️ This is beta software, things can break. Things which are n...
-
8
Scroll A high performance cross-platform native bounces ScrollView for React Native ...
-
9
Apps A high-performance, cross-platform animated header component for React Native applications Mar 26, 2023 2 min read
-
8
Create a Hand-Drawing Component Using React Native Skia ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK