You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| permissionDialogMessage |`string`| Android Only: Provide a Dialog Message for the Image Saving PermissionDialog. Defaults to empty string if not set |
100
102
| onGenerateBase64 |`function`| An optional function which accepts 1 argument `result` containing the base64 string of the canvas. Called when `getBase64()` is invoked. |
101
103
| onCanvasReady |`function`| An optional function called when the canvas is ready for interaction. |
104
+
| initialPaths |`array`| Array of paths to load into the canvas when it becomes ready. Uses native batch processing for optimal performance. Each path should follow the [Path object](#objects) format. |
105
+
| onInitialPathsLoaded |`function`| An optional function which accepts 1 argument `eventData`. Called when `initialPaths` have been processed and loaded into the canvas. `eventData` is an object with `{ loadedCount: number }` property containing the number of paths successfully loaded. |
| save(imageType, transparent, folder, filename, includeImage, cropToImageSize) | Save image to camera roll or filesystem. If `localSourceImage` is set and a background image is loaded successfully, set `includeImage` to true to include background image and set `cropToImageSize` to true to crop output image to background image.<br/>Android: Save image in `imageType` format with transparent background (if `transparent` sets to True) to **/sdcard/Pictures/`folder`/`filename`** (which is Environment.DIRECTORY_PICTURES).<br/>iOS: Save image in `imageType` format with transparent background (if `transparent` sets to True) to camera roll or file system. If `folder` and `filename` are set, image will save to **temporary directory/`folder`/`filename`** (which is NSTemporaryDirectory()) |
114
118
| getPaths() | Get the paths that drawn on the canvas |
115
119
| getBase64(imageType, transparent, includeImage, includeText, cropToImageSize) | Get the base64 string of the canvas. The result will be sent through the `onGenerateBase64` event handler. Parameters:<br/>- `imageType`: "png" or "jpg"<br/>- `transparent`: whether to include transparency<br/>- `includeImage`: whether to include background image<br/>- `includeText`: whether to include text<br/>- `cropToImageSize`: whether to crop to background image size |
120
+
| setInitialPaths(initialPaths) | Set initial paths to the canvas using native batch processing. This method is called automatically when the `initialPaths` prop is provided, but can also be called manually for dynamic path loading. |
| savePreference |`function`| A function which is called when saving image and should return an object (see [below](#objects)). |
257
262
| onSketchSaved |`function`| See [above](#properties)|
258
263
| onCanvasReady |`function`| An optional function called when the canvas is ready for interaction. |
264
+
| initialPaths |`array`| Array of paths to load into the canvas when it becomes ready. Uses native batch processing for optimal performance. Each path should follow the [Path object](#objects) format. |
265
+
| onInitialPathsLoaded |`function`| An optional function which accepts 1 argument `eventData`. Called when `initialPaths` have been processed and loaded into the canvas. `eventData` is an object with `{ loadedCount: number }` property containing the number of paths successfully loaded. |
259
266
260
267
#### Methods
261
268
@@ -312,6 +319,84 @@ Note: Because native module cannot read the file in JS bundle, file path cannot
The `initialPaths` prop allows you to pre-load paths into the canvas when it becomes ready. This feature uses native batch processing for optimal performance, making it ideal for loading saved sketches or collaborative drawing sessions.
@@ -412,10 +497,15 @@ Note: Because native module cannot read the file in JS bundle, file path cannot
412
497
413
498
---
414
499
415
-
The source code includes 7 examples, using build-in UI components, using with only canvas, and sync between two canvases.
500
+
The source code includes 9 examples, using built-in UI components, using with only canvas, sync between two canvases, and performance testing with initial paths loading.
416
501
417
502
Check full example app in the [example](./example) folder
418
503
504
+
### New Examples
505
+
506
+
-**Example 8**: API consistency testing for initial paths loading with various edge cases
507
+
-**Example 9**: Performance testing suite for large datasets using the new `initialPaths` feature
508
+
419
509
### Jest Setup
420
510
421
511
If you're using Jest in your project, you'll need to mock the TurboModule registry. Add the following to your Jest setup file:
0 commit comments