Ich verwende derzeit dieses Modul: https://github.com/mxmzb/react-native-gesture-detector. Ich möchte in der Lage sein, eine Linie aus den erzeugten Punkten zu zeichnen, aber es scheint nur Kreise auszugeben
Es hat eine Geste erstellen-Ansicht
<View style={{ position: relative, width: 100%, height: 100% }}>
<GesturePath
path={gesture.map(coordinate => {
if (recorderOffset) {
return {
x: coordinate.x + recorderOffset.x,
y: coordinate.y + recorderOffset.y,
};
}
return coordinate;
})}
color=green
slopRadius={30}
center={false}
/>
</View>
GesturePath wird wie folgt definiert
const GesturePath = ({ path, color, slopRadius, center = true }: GesturePathProps) => {
const baseStyle: ViewStyle = {
position: absolute,
top: center ? 50% : 0,
left: center ? 50% : 0,
opacity: 1,
};
return (
<>
{path.map((point, index) => (
<Animated.View
style={Object.assign({}, baseStyle, {
width: slopRadius,
height: slopRadius,
borderRadius: slopRadius,
backgroundColor: color,
marginLeft: point.x - slopRadius,
marginTop: point.y - slopRadius,
})}
key={index}
/>
))}
</>
);
};
Wenn Sie in dieser Ansicht zeichnen, umreißt sie den Pfad mit Punkten, etwa so
Ich möchte, dass es eine glatte Linie ist und nicht eine Reihe von Kreisen, die das obige Bild zeigt