Project is made in p5.js It can be found here: www.p5js.org
This project was inspired by an article on https://www.redblobgames.com/articles/visibility/ and another really amazing interactive bit I found on https://ncase.me/sight-and-light/
The project uses line segments rather than any polygons as boundary objects, in future it could be improved to cast rays on polygons like squares and rectangles. The algorithm would have to be revamped to output a single polygon with vertices for any continuous square/rectangle object.