Connecting the Dots in my Memory

Concept: My artwork depicts dots that may be interpreted as brain cells or fragments of a scattered memory. The lines that link these dots essentially show how I feel our brains attempt to connect the dots or connect the storyline of a memory. It’s an interactive simple project where the user can use the mouse to click to pause and see how much memory was recalled. One could also say that these dots are parts of different memories and they are causing internal chaos trying to link a specific experience, where some parts are distancing and some are getting mixed up. 

 

 

 

 

 

 

Code: The code I’m proud of is the nested loop that allowed me to connect the lines from the dots. I was struggling at first because I had to consider that “cells” is an array and I had to adjust the code accordingly to make it work.

function connectCells(cells) {
  let maxConnections = 10; // Maximum number of connections per cell

  // Loop through each cell as the source cell
  for (let i = 0; i < cells.length; i++) {
    let connectedCount = 0; // Counter for the number of connections made by the source cell

    // Loop through all cells again to consider them as potential target cells
    for (let j = 0; j < cells.length; j++) {
      // Ensure that the source cell is not the same as the target cell
      if (i !== j) {
        // Calculate the distance between the centers of the source and target cells
        let d = dist(cells[i].x, cells[i].y, cells[j].x, cells[j].y);

        // Check if the cells are close enough to be connected, and if the source cell
        // has not reached its maximum allowed connections
        if (d < 50 && connectedCount < maxConnections) {
          stroke(255, 150, 150); // Set the line color
          line(cells[i].x, cells[i].y, cells[j].x, cells[j].y); // Draw a line between the cells
          connectedCount++; // Increment the connection count for the source cell
        }
      }
    }
  }
}

Reflection: For this task, my initial brainstorming revolved around the concept of producing a blurred image to symbolize a hazy memory. However, I felt that executing this idea might be somewhat challenging at this stage. Nevertheless, I am content with my final piece, although I believe it could benefit from additional refinements to achieve a greater level of abstraction and realism in my eyes.

Reference:

https://stackoverflow.com/questions/41719843/connected-balls-not-working-p5-js

 

 

Leave a Reply