Ray-casting algorithm: Difference between revisions

→‎{{header|PureBasic}}: Updated code to allow vertices to be expressed in floating points
(→‎{{header|PicoLisp}}: Added PureBasic)
(→‎{{header|PureBasic}}: Updated code to allow vertices to be expressed in floating points)
Line 1,248:
=={{header|PureBasic}}==
The code below is includes a GUI for drawing a polygon with the mouse that constantly tests whether the mouse is inside or outside the polygon. It displays a message and changes the windows color slightly to indicate if the pointer is inside or outside the polygon being drawn. The routine that does the checking is called inpoly() and it returns a value of one if the point is with the polygon and zero if it isn't.
<lang PureBasic>ProcedureStructure inpoly(*p.POINT, List poly.POINT())point_f
x.f
Protected new.POINT, old.POINT, lp.POINT, rp.POINT, i, inside, *poly
y.f
EndStructure
Procedure inpoly(*p.point_f, List poly.point_f())
Protected.point_f new, old, lp, rp
Protected inside
If ListSize(poly()) < 3: ProcedureReturn 0: EndIf
LastElement(poly()): old = poly()
Line 1,279 ⟶ 1,284:
EndIf
 
NewList v.POINTpoint_f()
Define.POINTpoint_f pvp, mp
Define Col, EventID, mode.b, modetxt.s
Repeat
Anonymous user