Replies: 1 comment
-
Ended up using import type { SkPath } from '@shopify/react-native-skia';
import { Skia } from '@shopify/react-native-skia';
export const getPathContour = (path: SkPath) => {
'worklet';
const it = Skia.ContourMeasureIter(path, false, 1);
return it.next();
};
export const getPathLength = (path: SkPath) => {
'worklet';
return getPathContour(path).length();
};
/**
* Get the point of a path at a given length
* @param path {SkPath} Skia path to be processed
* @param length {number} Length of the path to get the point from. Value between 0 and 1
* @returns
*/
export const getPointOfPathAtLength = (path: SkPath, length: number) => {
'worklet';
const contour = getPathContour(path);
const totalLength = contour.length();
return contour.getPosTan(totalLength * length)[0];
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to know if it's possible to to get the coordinates of the points on the arc. Similar to cubic bezier formula?
Beta Was this translation helpful? Give feedback.
All reactions