react-native-canvas
react-native-canvas copied to clipboard
CanvasRenderingContext2D.isPointInPath is not working
CanvasRenderingContext2D.isPointInPath is not working. Whenever I try to use it, I get the error as in the image below.
Does anyone know about this issue?
Below is an example code similar to the code I wrote.
const Component = () => {
const handleCanvas = (canvas: Canvas) => {
if (!canvas) return
const ctx = canvas.getContext('2d')
canvas.width = WINDOW_WIDTH
canvas.height = WINDOW_HEIGHT
const circle = new Path2D(canvas)
circle.arc(200, 200, 50, 0, 2 * Math.PI)
ctx.fillStyle = 'red'
ctx.fill(circle)
/** below code is not working */
ctx.isPointInPath(210, 210, 'nonzero', circle)
}
return (
<>
<Canvas ref={handleCanvas} />
</>
)
}
This is not a bug, the syntax is invalid, as of the MDN specification: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/isPointInPath
isPointInPath(x, y)
isPointInPath(x, y, fillRule)
isPointInPath(path, x, y)
isPointInPath(path, x, y, fillRule)
ctx.isPointInPath(210, 210, 'nonzero', circle)
would expect that the first argument (210) is an instance of Path2D, which it isn't.