Midterm project Progress: Image generative art

Table of Contents

  1. Introduction
    • 1.1 Project Overview
    • 1.2 Objective
    • 1.3 Creative Approach
  2. Getting Started
    • 2.1 Setting Up p5.js
    • 2.2 Importing the Image
    • 2.3 Initializing the Random Walkers
  3. The Generative Process
    • 3.1 Pixel Color Averaging
    • 3.2 Random Walkers
    • 3.3 Real-time Drawing Effect
  4. Enhancing Creativity
    • 4.1 Adjusting Walker Behavior
    • 4.2 Modifying Averaging Techniques
    • 4.3 Experimenting with Color
  5. Conclusion
    • 5.1 Final Artwork
    • 5.2 Future Improvements
    • 5.3 Acknowledgments

1. Introduction

1.1 Project Overview

This documentation explores a creative generative art project developed using p5.js. The project involves generating unique and visually appealing artwork based on a given input image. The art is created by employing a combination of random walkers that traverse the canvas, averaging pixel colors, and providing a real-time drawing effect.

1.2 Objective

The primary objective of this project is to harness the potential of generative algorithms to transform an input image into a distinctive and visually intriguing artwork. By utilizing random walkers and pixel color averaging, this project aims to offer a creative and dynamic approach to image interpretation.

1.3 Creative Approach

The project’s creativity lies in its unique amalgamation of pixel color manipulation and random walker behavior. Instead of a straightforward one-to-one mapping of image pixels, the art is generated by iteratively averaging the colors of neighboring pixels. Additionally, the art’s dynamism is achieved through the use of random walkers that contribute to the image in real-time, giving it a captivating and evolving appearance.

2. Getting Started

2.1 Setting Up p5.js

To begin, ensure you have p5.js set up in your development environment. You can download the p5.js library from the official website (https://p5js.org/). Follow the installation instructions provided on the website.

2.2 Importing the Image

Start by importing the image you wish to transform creatively into your p5.js sketch. You can use the loadImage() function to load the image and display it on the canvas.

2.3 Initializing the Random Walkers

Create random walkers that will move across the canvas. Each walker’s behavior and appearance can be customized according to your creative vision. Initialize these walkers with random starting positions and directions.

3. The Generative Process

3.1 Pixel Color Averaging

The core of this project’s creativity lies in pixel color averaging. Instead of mapping image pixel colors one-to-one, calculate the average color of a pixel’s neighborhood (e.g., a 3×3 or 5×5 grid of surrounding pixels). This technique introduces a smoothing effect and adds uniqueness to the generated artwork.

3.2 Random Walkers

The random walkers contribute to the creative process by traversing the canvas and drawing pixel colors. Customize the walker’s step size, direction changes, and color selection. The random nature of the walkers ensures that each run generates a distinct artwork.

3.3 Real-time Drawing Effect

The magic happens when the walkers contribute to the drawing of the image in real-time. As walkers move across the canvas, they apply the averaged colors to the corresponding pixel locations. This real-time interaction creates an intriguing and dynamic visual effect as if the image is being drawn before your eyes.

4. Enhancing Creativity

4.1 Adjusting Walker Behavior

Experiment with different walker behaviors to achieve a variety of artistic effects. You can control parameters such as step size, direction changes, and the duration of each walker’s journey.

4.2 Modifying Averaging Techniques

Tweak the pixel color averaging technique by adjusting the size and shape of the pixel neighborhood used for averaging. Experimenting with different neighborhood sizes and shapes can yield diverse visual outcomes.

4.3 Experimenting with Color

Explore the creative potential of color by experimenting with different color schemes, blending modes, or even introducing random variations in color selection for each walker. This allows for further artistic expression.

5. Conclusion

5.1 Final Artwork

Upon completing your generative art project, you will have a unique and visually captivating piece of artwork that creatively transforms the input image.

5.2 Future Improvements

Consider future enhancements, such as optimizing performance, adding interactivity, or integrating additional creative elements into your project.

5.3 Acknowledgments

Give credit to any resources, libraries, or individuals who have inspired or contributed to your project. Acknowledging your sources is essential in the world of creative coding.

In summary, this documentation provides a comprehensive overview of the generative art project created using p5.js. By creatively combining random walkers, pixel color averaging, and real-time drawing, you can produce dynamic and visually appealing artworks that showcase the power of generative algorithms in the world of art and creativity.

 

Assignment 4: Harmonic Motion of Gaussian Distribution

Project Description

Overview

This project is an interactive visual representation of simple harmonic motion, inspired by the Gaussian distribution curve, using P5.js. It creates a captivating display of 3D hexagons that rotate in the XY-plane while also oscillating in the Z-axis. Each hexagon has a progressively smaller radius than the one before it and undergoes harmonic motion both in terms of its position and color, resembling the shape of a Gaussian distribution curve.

Motivation

The motivation behind this project stems from the fascination with the Gaussian distribution, also known as the normal distribution or bell curve. The Gaussian distribution is a fundamental concept in statistics and probability theory, frequently encountered in various scientific and real-world contexts. It describes the probability distribution of a continuous random variable and is characterized by its symmetric, bell-shaped curve.

This project seeks to bridge the gap between the abstract beauty of mathematical concepts and their visual representation in art and technology. By drawing inspiration from the Gaussian distribution, it aims to provide an engaging and aesthetically pleasing way to explore the principles of simple harmonic motion. The visual resemblance to the Gaussian curve adds a layer of intrigue and connection to a concept that might otherwise be considered purely mathematical.

Project Appearance

The project presents a visually stunning 3D animation that draws inspiration from the Gaussian distribution curve. Here’s what you can expect:

  • Hexagons: There are 50 hexagons in total, each positioned in 3D space. The hexagons are arranged in a spiral pattern, with each hexagon having a smaller radius than the previous one, creating a visually appealing tapering effect.
  • Rotation: Each hexagon continuously rotates in the XY-plane. The rotation is driven by trigonometric functions, with the cos() function controlling the x-coordinate and the sin() function controlling the y-coordinate. This results in a circular movement for each hexagon, but with distinct positions and paces for each one.
  • Harmonic Motion: The project utilizes the sin() function on the current time value to manipulate the z-coordinate of each hexagon. This creates a mesmerizing effect where each hexagon appears to rise and fall in a harmonic motion pattern along the Z-axis, resembling the peaks and troughs of a Gaussian distribution curve.
  • Color Transformation: The project goes one step further by applying harmonic motion to the color of each hexagon. Custom RGB colors are generated by applying sin() and cos() functions to the time value. As a result, the colors of the hexagons smoothly transition, creating a beautiful visual representation that closely resembles the colors associated with a Gaussian distribution curve.

Demo

Link to the source code

Conclusion

In summary, this P5.js project is a captivating visualization of simple harmonic motion in 3D space, inspired by the shape of a Gaussian distribution curve. It features a mesmerizing spiral of rotating hexagons, with each hexagon undergoing harmonic motion along the Z-axis and experiencing a harmonious color transformation that evokes the colors of a Gaussian distribution. The project beautifully bridges the worlds of mathematics, art, and coding, offering a visually striking and educational representation of harmonic motion and probability distributions.

Week 3 Assignment

Concept

The “2D Simulation of 3D Object with Attractors and Movers” is a P5.js project that explores the behavior of a simulated 3D object within a 2D plane. The core concept involves creating an illusion of three-dimensionality through the interaction of attractors and movers in a confined space. Here’s how the concept breaks down:

  • Attractors: The project begins by introducing invisible attractors, positioned at the four vertices of a square. These attractors act as gravitational centers, exerting forces on nearby objects.
  • Movers: Movers are dynamic entities with mass and radius. They are introduced into the scene and interact with the attractors and each other. The movers are attracted to the invisible attractors, simulating gravitational forces. Additionally, movers attract each other, contributing to the complex dynamics of the simulation.
  • Initial Direction: To establish an organized start, the movers’ initial velocity vectors are set to be perpendicular to their position vectors. This arrangement ensures that all movers begin moving in the same direction.
  • Visual Illusion: The project employs lines connecting each pair of movers, creating a visual effect resembling a rotating 3D object. This illusion is achieved in a 2D plane, as P5.js primarily supports 2D graphics.
  • Boundary Constraints: To introduce chaos and turbulence into the simulation, movers are constrained by the boundaries of the canvas. When a mover reaches the boundary, it reverses its velocity, contributing to the overall dynamics and eventual chaos of the system.

Inspiration

The inspiration for this project likely draws from the desire to replicate the complex and chaotic movements of objects in a 3D space using the capabilities of P5.js, a 2D graphics library. The concept of simulating gravity and interactions between objects is a common theme in physics simulations and computational art.

Demo

Link to code

Reflection

The project successfully achieves its goal of creating a visually intriguing simulation of a 3D object’s behavior within a 2D plane. It demonstrates the dynamic interplay between attractors and movers and how this interaction can lead to chaotic and unpredictable motion.

Ideas for Future Work or Improvements

  1. Enhanced Visualization: Exploring ways to improve the visual representation of the rotating 3D object. This could involve using different shapes or rendering techniques to make the illusion more convincing.
  2. User Interaction: Adding user controls to manipulate the attractors or introduce new movers during runtime, allowing users to interact with and influence the simulation.
  3. Realistic Physics: Experimenting with more advanced physics simulations, such as introducing damping, or elastic collisions between movers.
  4. Performance Optimization: Optimizing the code to handle a larger number of movers and attractors without sacrificing performance. Techniques like quad trees for collision detection can be beneficial.

 

Week 2 Assignment: Documentation (Zulfkhar Maukey)

Raindrop Simulation Documentation

Introduction

The Raindrop Simulation is a p5.js project that simulates the behavior of raindrops falling from the sky. This project is an example of using rules and physics to replicate a real-world natural phenomenon. In this documentation, we will provide a detailed description of what the simulation does, how it works, and how users can interact with it.

Project Description

What It Does

The Raindrop Simulation replicates the following characteristics of raindrops:

  1. Gravity: Raindrops are affected by gravity, causing them to accelerate as they fall.
  2. Wind: A simulated wind force pushes raindrops horizontally, creating a drifting effect.
  3. Variable Gravity: Users can interact with the simulation by temporarily increasing the gravity force when the “Up Arrow” key is pressed. This causes raindrops to fall faster and create a denser rainfall.
  4. Splash Effect: When a raindrop hits the ground (the bottom of the canvas), it creates a splash effect.
  5. Raindrop Removal: Users can decrease the gravity force by pressing the “Down Arrow” key, making raindrops fall more slowly. This allows for the removal of raindrops from the simulation.
User Interaction

The user can interact with the Raindrop Simulation using keyboard inputs:

  • Up Arrow Key: When pressed, it increases the gravity temporarily, causing raindrops to fall faster and more intensely.
  • Down Arrow Key: When pressed, it decreases the gravity, making raindrops fall more slowly. This also allows for the removal of raindrops from the simulation.

Implementation

Setup and Draw Functions

In the p5.js setup function:

  • The canvas is created with a size of 400×400 pixels.
  • A predefined number of raindrops (100 in this case) are created and stored in an array.
  • The initial gravity value is set to 0.2.

In the p5.js draw function:

  • The canvas is cleared with a light gray background (RGB 220, 220, 220).
  • Wind force is applied to each raindrop, creating a horizontal drifting effect.
  • Gravity is applied to each raindrop, causing them to accelerate vertically.
  • The position and appearance of each raindrop are updated and displayed on the canvas.
Raindrop Class

The Raindrop class represents individual raindrops in the simulation. Each raindrop has the following properties and methods:

  • constructor: Initializes the position, velocity, length, and splash state of each raindrop.
  • applyForce(force): Applies a force vector to the raindrop, affecting its velocity.
  • update(): Updates the raindrop’s position based on its velocity and applies constraints to keep it within the canvas.
  • splash(): Checks if a raindrop has hit the ground and creates a splash effect if it has.
  • display(): Renders the raindrop as a blue line and calls the splash() method to display the splash effect.

Demo

Full-source code

Conclusion

The Raindrop Simulation project successfully replicates the behavior of falling raindrops and provides an interactive experience for users. It showcases how computational rules and physics can be used to simulate natural phenomena. Here are some key reflections on the project:

  • Realism: The simulation captures the basic behavior of raindrops, including gravity, wind, and the splash effect, providing a visually convincing representation.
  • Interactivity: User interaction via the keyboard adds an engaging element, allowing users to control the intensity of the rainfall and observe the immediate impact on the simulation.
  • Educational Value: This project serves as an educational tool, demonstrating principles of physics and programming in an accessible and fun manner.

While the Raindrop Simulation is functional and engaging, there is room for improvement and expansion. Here are some ideas for future work:

  1. Particle Interaction: Add more complex interactions between raindrops, such as collisions or cohesion, to enhance realism.
  2. Dynamic Wind: Implement a more dynamic wind pattern, including changes in wind direction and intensity over time.
  3. Realistic Splash: Enhance the splash effect by considering the angle and speed of impact to create more realistic splashes.

Week 1 Assignment: Walker Documentation (Zulfkhar Maukey)

Introduction

The Walker is an interactive p5.js project that creates a constantly morphing creature that moves in random directions on a canvas. This project utilizes JavaScript and the p5.js library to generate a visually intriguing and ever-changing artwork. In this documentation, we will provide a detailed description of what the Walker does, what the user can expect, and any interactive elements involved.

Project Description

What It Does

The Walker is an abstract creature that appears to be walking across the canvas. It constantly changes its shape, giving it an amorphous and unpredictable appearance. The key features of the Walker project are as follows:

  1. Random Movement: The Walker moves in random directions, making it appear as if it is wandering aimlessly across the canvas.
  2. Mouse Interaction: There is a 50% chance that the Walker will move towards the mouse cursor’s position. When this happens, it appears as though the creature is attracted to the mouse.
  3. Shape Morphing: The creature’s shape is continually changing. It starts with a predefined shape made up of random vertices, and these vertices are updated randomly, causing the creature to morph over time.

User Interaction

The user’s interaction with the Walker project is minimal but plays a crucial role in shaping the creature’s movement. Here’s what the user can do:

  • Mouse Movement: When the user moves their mouse cursor within the canvas, the Walker may respond by moving towards the mouse cursor with a 50% probability. This interaction creates a dynamic relationship between the user’s cursor and the creature’s movement.

Implementation

Walker Class

The Walker is implemented as a JavaScript class with the following methods:

  • Constructor: The constructor sets up the initial position of the Walker at the center of the canvas and initializes the creature’s shape with a random set of vertices.
  • step(): This method controls the Walker’s movement. It calculates a random number to determine whether the Walker should move towards the mouse cursor or in a random direction. If the decision is to move towards the mouse, it adjusts the position of the Walker accordingly. Otherwise, it moves the Walker randomly. The Walker’s position is constrained within the canvas boundaries.
  • display(): The display() method is responsible for rendering the Walker on the canvas. It draws the creature as a shape with constantly morphing vertices.
  • updateBounds(): This method randomly updates the positions of the creature’s vertices, causing it to morph and change shape.

Setup and Draw Functions

In the p5.js setup function:

  • The canvas is created with a size of 400×400 pixels.
  • The background is set to a light gray color (RGB 220, 220, 220).
  • An instance of the Walker class is created.

In the p5.js draw function:

  • The step() method of the Walker is called, updating its position.
  • The display() method of the Walker is called to draw the creature on the canvas.

Demo

Full-source code

Conclusion

The Walker project is an interactive P5.js artwork that combines randomness and user interaction to create an ever-changing and visually intriguing creature. Users can observe the creature’s unpredictable movement and, through their mouse cursor, influence its direction. This project serves as an example of how programming and creativity can come together to produce interactive and captivating visual experiences.

Reading Response (Chapter 1)

The ideas presented in this chapter really resonate with me because they emphasize the beauty of simplicity, in explaining phenomena. The examples, like how ant colonies function or how basic rules can account for patterns in nature show us that the world operates on principles. This reinforces my belief in the elegance of simplicity and its role in helping us understand the complexities of life.

Moreover the chapter highlights the significance of collaboration. It makes me think about how scientific research’s evolving. As someone who values approaches it’s reassuring to witness how computers have bridged the gap between theory and experimentation fostering collaboration among scientists from fields. This convergence has potential to unlock insights and solutions to complex problems by harnessing expertise from various disciplines.

However it also raises questions about finding a balance between specialization and interdisciplinary cooperation. While specialization allows for exploration, within a field this chapter suggests that breakthroughs often result from collaboration and sharing ideas across disciplines. It leaves me contemplating how we can strike the balance as we pursue understanding and problem solving – ensuring that we leverage both specialized expertise and interdisciplinary synergy.