implemanting freehand crop in android

后端 未结 3 495
猫巷女王i
猫巷女王i 2021-01-02 11:33

i m trying to implement freehand crop in android using canvas. i use drawPath and store it in List and draw it in canvas path drawing ok,

like this

3条回答
  •  Happy的楠姐
    2021-01-02 12:04

    Lets look at a bit more complex example:

    example

    The red point is the point you want to test. You have to find the edges that cross the y coordinate of the red point. In this example 4 edges cross the y coordinate (the blue points).

    Now test how much intersections you get on the left side and on the right side of the point you want to check. If there is an odd number of intersections on both sides the point is inside the shape.

    update: you can find a more detailed description of this algorithm here

提交回复
热议问题