Coding shadows
Here's a small project I wrote in a few hours. It's a Python3 program that calculates and displays shadows based on information read from a JSON file. Firstly, the user is presented with a list of files ending in .json in the current directory. They must enter a valid filename to proceed. The JSON file is parsed. It contains the resolution of the image, the location of the light in the scene and the location and radius of the circles (which cast shadows) in the image. Each light and shape in the scene instantiate a new object from an appropriate class, with the afforementioned data stored in the object's attributes. These objects are appended to an array. The program then iterates through each light in the lights array and each pixel in the x and y axis (from 0 to the total width and height of the image). It determines if the path from the light source to the pixel in question is obstructed by a shape. To accomplish this, the program determines the equation of the s...