ArrayList<LightSource> ls = new ArrayList<LightSource>();
lightmap = new float[width / scale][height / scale];
for (int i = 0; i < 11; i++)
ls.add(new LightSource(100, 100, 100 / scale));
ls.get(6).pos.y = height / scale / 2;
ls.get(7).pos.y = height / scale - 10;
ls.get(8).pos.x = width / scale - 10;
ls.get(9).pos.x = width / scale - 10;
ls.get(9).pos.y = height / scale / 2;
ls.get(10).pos.x = width / scale - 10;
ls.get(10).pos.y = height / scale - 10;
ls.get(0).pos.x = mouseX / scale;
ls.get(0).pos.y = mouseY / scale;
for (int i = 1; i < 5; i++) {
ls.get(i).pos.x = int(sin((millis() + 1500 * i) * 0.001) * 100 / scale + width / scale / 2);
ls.get(i).pos.y = int(cos((millis() + 1500 * i) * 0.001) * 100 / scale + height / scale / 2);
text(round(frameRate), 0, 10);
LightSource(float x, float y, int r) {
int getLight(int x, int y) {
float d = sqrt(sq(pos.x - x) + sq(pos.y - y));
return int(map(d, 0, rad, 255, 0));
for (int y = 0; y < height / scale; y++) {
for (int x = 0; x < width / scale; x++) {
for (int i = 0; i < ls.size(); i++) {
b = ls.get(i).getLight(x, y);
if (lightmap[x][y] >= 255) {
for (int y = 0; y < height / scale; y++) {
for (int x = 0; x < width / scale; x++) {
fill(0, 255 - lightmap[x][y]);
rect(x * scale, y * scale, scale, scale);