Warpy
at the moment i try to understand your code.
i have some difficulties with
i understand the line
If (y1-midy)*(y2-midy)<0
if the horizontal ray originating from (midx,midy) hits the edge Points of the line that is checked hits will be zero. so "mid" is outside the polygon. i´ve made a little sketch of 3 cases i can imagine that are difficult.

case 1 hits will be zero -> point ist outside the polygon
case 2 hits will be zero -> point ist outside the polygon
case 3 seems to make trouble. hits will be 1 but it is outside the polygon.
the horizontal ray will hit two edge points both will make hits zero an then a normal line that will make hits to one. the result will be 1 and so it is inside the polygon.
another difficulty i have is to understand
ix#=x1+(x2-x1)*(midy-y1)/(y2-y1)
If ix<midx hits:+1
i don´t get it. what are you calculating here?
the result of your code seems to have a bug. it seems that the last point i set is causing trouble

i really try to understand your code.
thanks for your great effort so far!!!
at the moment i try to understand your code.
i have some difficulties with
If (y1-midy)*(y2-midy)<0 ix#=x1+(x2-x1)*(midy-y1)/(y2-y1) If ix<midx hits:+1 EndIf
i understand the line
If (y1-midy)*(y2-midy)<0
if the horizontal ray originating from (midx,midy) hits the edge Points of the line that is checked hits will be zero. so "mid" is outside the polygon. i´ve made a little sketch of 3 cases i can imagine that are difficult.
case 1 hits will be zero -> point ist outside the polygon
case 2 hits will be zero -> point ist outside the polygon
case 3 seems to make trouble. hits will be 1 but it is outside the polygon.
the horizontal ray will hit two edge points both will make hits zero an then a normal line that will make hits to one. the result will be 1 and so it is inside the polygon.
another difficulty i have is to understand
ix#=x1+(x2-x1)*(midy-y1)/(y2-y1)
If ix<midx hits:+1
i don´t get it. what are you calculating here?
the result of your code seems to have a bug. it seems that the last point i set is causing trouble
i really try to understand your code.
thanks for your great effort so far!!!