rocinantealpha

reference / collision

cast

The first item a line meets, from its from to its to: a record with item, point, normal and distance, every field 0 (and no item) when it meets nothing.

fill goldwalls = [ { pos: { 300, 100 }, size: { 40, 100 } } { pos: { 200, 40 }, radius: 30 } ]ray = { from: { 20, 150 }, to: { 380, 150 } }h = cast ray wallsfor each w in walls [ circle at w.pos radius w.radius ]rect at 300 100 size 40 100line from ray.from to h.point stroke tomato thickness 3
what it draws: the whole window, 400 by 300
What the example of cast draws

How to write it

cast line list

Gives a value.

Related