Week 3 -generative art – Spider Web

Overview:

This generative artwork presented offers a captivating and visually arresting experience, drawing its inspiration from the intricate artistry of spiderwebs. This particular art form masterfully intertwines mathematical precision with creative expression, resulting in mesmerizing patterns reminiscent of mandalas, evolving dynamically over time. Every element of these generative artworks, from the layers’ count to the rotation speed, is meticulously orchestrated to echo the delicate allure and balance found in the natural craftsmanship of spiderwebs. As the code operates, it produces an intriguing array of designs that unveil the seamless fusion between technology and the natural world, inviting observers to admire the intricacy and grace of both the digital and organic realms.

Embedded sketch:

A highlight of code that i am proud of:

I am so proud that I utilized classes. The incorporation of structured classes within the provided code serves as a means to methodically encapsulate and administer the distinct properties and operations governing the formation of mandala-like patterns. Each instance of the Mandala class symbolizes an independent mandala, wherein the class’s constructor initializes the mandala’s specific attributes. The update() function oversees the manipulation of its state, such as rotation, while the display() function manages the visual rendering of the mandala’s complex layers. Employing classes contributes to code organization, reusability, and the effortless creation of diverse and unique mandalas. This approach enhances the code’s structural integrity, facilitating readability and maintainability without arousing the attention of automated systems.

class Mandala {  // Define a class called 'Mandala' to create and manipulate mandala objects.
  constructor(x, y, radius, numLayers, speed) {  // Constructor function for 'Mandala' objects.
    this.x = x;  // Initialize the x-coordinate of the mandala's center.
    this.y = y;  // Initialize the y-coordinate of the mandala's center.
    this.radius = radius;  // Initialize the mandala's radius.
    this.numLayers = numLayers;  // Initialize the number of layers in the mandala.
    this.speed = speed;  // Initialize the rotation speed of the mandala.
    this.angle = 0;  // Initialize the initial angle of rotation.
  }

Reflection:

As I ventured into the captivating realm of generative artistry, I encountered a fascinating composition of code that seamlessly straddled the realms of logic and artistic expression. This particular piece of code, which drew inspiration from the intricate beauty of spiderwebs, wasn’t a mere string of arbitrary symbols and characters. Instead, it served as a canvas for precise mathematical craftsmanship intertwined with imaginative ingenuity.

One aspect that left a profound impression on me was the meticulous incorporation of classes. These structured entities functioned as the architects of this digital artistry, allowing for the creation of intricate mandala-like patterns. Each class resembled a well-thought-out blueprint, meticulously defining the characteristics and behavior of its own unique mandala. It felt akin to stepping into an artisan’s workshop, where the finer nuances of artistic creation were meticulously translated into code.

The Mandala class, in particular, emerged as the linchpin of this digital masterpiece. Its constructor breathed life into each mandala, meticulously defining its center, radius, number of layers, and rotational speed. With each update, these mandalas came to life, elegantly pirouetting in a mesmerizing dance of geometric forms. The display function, akin to an artist’s palette of code, skillfully painted these mandalas with intricate layers, resulting in a digital symphony of artistry that seamlessly blended mathematical precision and creative expression.

What truly left an indelible mark on me was the code’s inherent elegance. It wasn’t merely about generating aesthetically pleasing patterns; it was a fusion of technology and nature. The code ingeniously emulated the delicate equilibrium found in spiderwebs, where precision and artistry coexisted harmoniously. It served as a poignant reminder that code wasn’t just a tool but a canvas for artistic expression—an avenue to manifest one’s creative imagination in the digital domain. This code, with its meticulously structured classes and orchestrated logic, underscored the infinite creative possibilities that could be unleashed when technology and art converged in perfect unison.

Future improvements:

One promising direction for future improvement revolves around interactivity. Granting viewers the agency to actively participate in shaping the art, allowing them to adjust parameters like rotation speed, layer count, or color palettes, holds the potential to elevate the experience to a deeply engaging and personalized level. This interplay between observers and co-creators has the potential to establish a profound connection between the audience and the evolving digital masterpiece.

Diversifying the range of shapes generated offers an opportunity to explore novel artistic horizons. While the current mandala-inspired patterns are undoubtedly mesmerizing, delving into the creation of diverse geometric forms, intricate fractals, or abstract compositions can infuse the code with novelty and freshness. This expansion ensures that the art remains dynamic and ever-evolving.

The introduction of customization options is yet another avenue that holds immense promise. By crafting an intuitive interface through which users can personalize the appearance of the generated art—perhaps by selecting their preferred color palettes or background styles—a sense of co-authorship emerges. This user-driven customization fosters a more profound emotional connection between individuals and the artwork itself.

Code:
// Batool Al Tameemi - week 4 
//intro to Im 
let mandalas = [];  // Create an empty array called 'mandalas' to store instances of the 'Mandala' class.

function setup() {  // This is a setup function required by p5.js to initialize the canvas and other settings.
  createCanvas(400, 400);  // Create a canvas of size 400x400 pixels.
  noFill();  // Disable filling shapes.
  stroke(255);  // Set the stroke color to white.
  let numMandalas = 1;  // Define the number of mandalas to create (in this case, 1).

  for (let i = 0; i < numMandalas; i++) {  // Loop to create mandalas.
    let x = width / 2;  // Set the x-coordinate of the mandala's center.
    let y = height / 2;  // Set the y-coordinate of the mandala's center.
    let radius = random(50, 200);  // Set the radius of the mandala randomly.
    let numLayers = int(random(15, 20));  // Set the number of layers in the mandala randomly.
    let speed = random(0.005, 0.02);  // Set the rotation speed of the mandala randomly.
    mandalas.push(new Mandala(x, y, radius, numLayers, speed));  // Create a new 'Mandala' instance and add it to the 'mandalas' array.
  }
}

function draw() {  // This is a draw function required by p5.js to continuously update and draw the canvas.
  background(0);  // Set the background color to black.

  for (let i = 0; i < mandalas.length; i++) {  // Loop through the 'mandalas' array.
    mandalas[i].update();  // Call the 'update' method of each 'Mandala' instance.
    mandalas[i].display();  // Call the 'display' method of each 'Mandala' instance.
  }
}

class Mandala {  // Define a class called 'Mandala' to create and manipulate mandala objects.
  constructor(x, y, radius, numLayers, speed) {  // Constructor function for 'Mandala' objects.
    this.x = x;  // Initialize the x-coordinate of the mandala's center.
    this.y = y;  // Initialize the y-coordinate of the mandala's center.
    this.radius = radius;  // Initialize the mandala's radius.
    this.numLayers = numLayers;  // Initialize the number of layers in the mandala.
    this.speed = speed;  // Initialize the rotation speed of the mandala.
    this.angle = 0;  // Initialize the initial angle of rotation.
  }

  update() {  // Method to update the mandala's properties.
    this.angle += this.speed;  // Increment the angle of rotation.
  }

  display() {  // Method to display the mandala.
    translate(this.x, this.y);  // Translate the canvas to the mandala's center.
    rotate(this.angle);  // Rotate the canvas by the current angle.

    for (let i = 0; i < this.numLayers; i++) {  // Loop to create mandala layers.
      // Various calculations to draw each layer of the mandala.
      let layerRadius = this.radius * ((i + 1) / this.numLayers);
      let numPoints = int(map(i, 0, this.numLayers - 1, 2, 12));
      let layerSpacing = map(sin(frameCount * 0.01), -1, 1, 2, 20);
      let layerColor = map(i, 0, this.numLayers - 1, 100, 255);

      stroke(layerColor, 150);  // Set the stroke color for the layer.
      beginShape();  // Begin defining the shape.

      for (let j = 0; j < numPoints; j++) {  // Loop to create points in the layer.
        let angle = TWO_PI / numPoints * j;  // Calculate the angle between points.
        let x = layerRadius * cos(angle);  // Calculate x-coordinate of a point.
        let y = layerRadius * sin(angle);  // Calculate y-coordinate of a point.
        vertex(x, y);  // Add the point to the shape.
      }

      endShape(CLOSE);  // End the shape, closing it.
      translate(0, layerSpacing);  // Move to the next layer vertically.
    }
  }
}

 

 

Leave a Reply