Categories
creative coding lab

Mini Project 5: object dancers

https://editor.p5js.org/calistalu/sketches/VugfRka5s

https://github.com/calistalu/mini_project_5_object_dancer_2023_10_31_00_58_53

Brief Description and Concept

This particular seagull gathered significant popularity among young people, largely due to its adorable appearance and keen eyes. While it’s often seen in plush toys and internet memes, I was inspired to bring it to life through animation. Its eyes will follow your mouse’s direction. It turned out that it’s even cuter when dancing around!

Demo/Visual Documentation

 original version

demo 

Coding

update() {
angleMode(DEGREES);
this.ang = sin(frameCount * 10) * 8;
this.cute1 = sin(frameCount * 20);
this.cute2 = sin(180 + frameCount * 20);
this.e1 = map(mouseX, 0, width, 12, 18);
this.e2 = map(mouseY, 0, height, 93, 104);
this.e3 = map(mouseY, 0, height, 72, 82);
this.x += this.spd;
if (this.x >= width - 100 || this.x <= 100) {
this.spd *= -1;
}
}

Several properties are manipulated in the updated( ) method, which is a central to achieving the seagull’s dance movement. The challenge lies in determining which properties are required for the dancer (the seagull) before writing the constructer function. Initially, I individually adjusted the positions of the vertex resulting in lengthy and complex code.

 

update() {
angleMode(DEGREES);
this.bx5-=sin(frameCount*this.m1)
this.bx6+=sin(frameCount*this.m1)
this.bx1+=sin(frameCount*this.m1)
this.bx2+=sin(frameCount*this.m1)
this.bx3-=sin(frameCount*this.m1)
this.bx4-=sin(frameCount*this.m1)

this.ang = sin(frameCount * 10) * 8;
this.wy1 -= sin(frameCount * 10) * 3;
this.wx3 += sin(frameCount * 10);
this.wy2 -= sin(frameCount * 10) * 3;
this.wx4 -= sin(frameCount * 10);

}

However, I later discovered a more concise approach. By creating “this.cute1 = sin(frameCount * 20)” and applying it to all the vertex coordinates, I simplified the code significantly. Its additional benefit is to allow easily introduce “this.cute2 = sin(180 + frameCount * 20)” to achieve phase difference in the left and right body parts. 

Reflection/Lessons Learned

  1. By encapsulating data (properties) and behavior (methods) within a class, I ensure that the class is self-contained. This means that the class doesn’t rely on any external code for its function, which make it easier to organize the code. I can create instances of my class in various parts of my project, as well as combine everyone’s classes into one project, increasing flexibility, reducing redundancy and saving time. 
  2. When working on a project that involves multiple contributors, ensuring that your code harmonizes with others can be challenging. Differences in coding style, naming conventions, and assumptions may lead to harmonization issues. These challenges can result in debugging difficulties and delays in project progress. The application of OOP is a significant advantage when dealing with these situations.
  3. Modularity refers to the division of a project into smaller, independent components. In the case of the “Seagull” class, it has methods for construction, update and display. Each of these functions can be encapsulated within the class, allowing for easy modifications without affecting other parts of the project. For instance, I can modify the updating (dancing) algorithm in the “Seagull” class without altering the code responsible for drawing the basic shape of the seagull.

    Reusability implies that a class can be used in different contexts or projects. For the “Seagull” class, it could be employed not only in my current project but also in future projects or by our professor. This reusability is possible because the class is self-contained, making it easy to integrate into new systems without extensive modifications. For instance, when it is combined into the collection of all the dances developed by our classmates, the “Seagull” class can be utilized without rewriting the entire code.

Categories
creative coding lab

Project A: Cyberpond ecosystem

https://github.com/calistalu/projectA

https://editor.p5js.org/calistalu/sketches/GXAv3p3sl

Part 1

Project description:

Calista Lu,
CYBERPOND ECOSYSTEM, 2023
Digital water life inhabiting in a cyber world

  • The Elevator Pitch.
    Cyberpond Ecosystem revolves around exploring various creatures inhabiting in a tiny cyber pond. It simulates a school of fish gracefully navigating the pond’s water, with their predator chasing all the way behind.
  • Abstract.
    Within the Cyberpond Ecosystem,  the school of fish exhibit a range of interactive behaviors with the predator. Users are empowered to interact with these creatures using their mouse, aiming to reflect how human intervention can disrupt the delicate equilibrium of nature’s complicated operations. The core objective of this project is to provoke contemplation about ecosystems through a virtual experience, emphasizing the interconnectedness of life within nature. It serves as a reminder that every organism plays a role in sustaining the stability of an ecosystem, and any alteration has the potential to reverberate throughout the entire system.

User interaction with the school of fish

Human intervention 

Part 2

1) Process: Design and Composition

My project started from its initial concept of simulating a school of fish:

Initial design of school of fish

Then I decided to introduce vibrant colors in order to create a striking contrast with the dark background. It occurred to me that I could correlate the color with the direction of the fish’s movement, controlled by sin(a) and cos(a), and incorprate user interaction through mapping the value of mouseX. What’s more, using the noise function to create an organic feel is what I have found of value to build upon in your project. Perlin noise is smooth and continuous (and repeatable), meaning that it doesn’t exhibit sudden changes. This property makes it ideal for generating realistic, organic-looking textures. I utilized the two dimension noise to subtly shift the positions of the fish particles in each frame (picked in align with p.x and p.y, similar to vertex), creating such a flow field. It took several iterations to get to where it is now:

The ripple effect of mouse interaction

The final effect

2) Process: Technical:

One of the most significant technical challenge I faced was integrating user interaction with the predator. I specified a series of the vertex coordinates that construct the circle shape of predator by connecting them. I added noise function to their coordinates to produce the effect of blurring the edges. After I’ve decided to make the predator move towards the direction of mouse when mouse is pressed, I created two different mode for its movement when mouse is pressed or not inspired by my professor Eric. However, that brings about another problem: its position would reset when switching mode. That’s because I used a different method for the predator compared with the fish. I mapped two dimension noise to the width and height of the canvas using the following code:

translate(noise(inc/5)*width, noise(1000+inc/5)*height);

This approach ensured that the predator remained within the canvas and rarely reached its edges due to the property of noise function. However the shortcomings are also obvious: It would be impossible to control the start position of its motion after switching mode. As a result, I had to make a compromise and adapt the following code for a smoother user experience, even though the predator was more likely to approach the canvas’s edges, diminishing visual comfort:

let xspd = map(noise(inc), 0, 1, -2, 2);
let yspd = map(noise(1000 + inc), 0, 1, -2, 2);

xx = posX + xspd;
yy = posY + yspd;

posX = xx;
posY = yy;

posX = constrain(posX, 0, width);
posY = constrain(posY, 0, height);

Sometimes it would be a bit frustrating to make such compromise due to technical limitations, but it is a reflection of the real-world constraints we encounter in the creative process. Even more frustrating, Sometimes it turns out to be a very low-level error after debugging for a long time, like we should use ‘x>a && x<b’ instead of  ‘a<x<b’ in p5.js or one local value should have been set as a global value. 

3) Reflection and Future Development

I greatly benefited from the extensive feedback provided by my audience during my presentation. I incorporated some of their suggestions, such as eliminating distracting changes in stroke color and making the smaller fish also respond to mouse presses, not just the large predator. Looking ahead, for future improvements, I plan to introduce more diverse creatures into the cyber pond, each with unique behaviors. Additionally, I intend to explore aspects such as growth, reproduction, flocking dynamics, and potentially integrate sound effects to enhance user interaction.

In conclusion, the core objective of this project is to provoke contemplation about ecosystems through a virtual experience, emphasizing the interconnectedness of life within nature. It serves as a reminder that every organism plays a role in sustaining the stability of an ecosystem, and any alteration has the potential to reverberate throughout the entire system.

Tutorial credits:

Coding Challenge #36: Blobby! by The Coding Train [https://www.youtube.com/watch?v=rX5p-QRP6R4&list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH&index=44]

Easy Perlin Noise Flow Fields by Barney Codes [https://www.youtube.com/watch?v=sZBfLgfsvSk]

Categories
creative coding lab

Reading response 2: Long Live the Wub

The author highlighted a range of benefits the Internet offered, and universality is the foundation of them. For example, NYU Shanghai websites are typically designed to work on various devices and browsers, ensuring a broad audience can access the content globally. I can quickly research and learn about a wide range of topics, from educational resources to news articles. 

However, alongside its convenience, the internet has also given rise to some ill effects. The article recounts an incident in 2008 when a company developed an ISP capable of peering into the packets of information it transmitted. This capability raises significant privacy concerns, including unauthorized access to personal data, targeted advertising, and potential data security risks. Personally, I share similar worries and exercise utmost caution when browsing websites to safeguard my online privacy.

Universality refers to the principle that a technology or system should be accessible and usable to everyone, regardless of their location, language, or abilities. Universality is a core concept of the World Wide Web, where websites and content are designed to be accessible to a global audience. Isolation, on the other hand, stands in contrast to universality. It represents the idea of keeping something separate or restricted. In my experience on the web, certain closed app stores or subscription-based services can represent isolation by limiting access to users who meet specific criteria.

Open Standards are protocols and technologies that are openly available for anyone to implement, which develops its diversity, richness and innovation. An example is HTML that we are learning currently, a standard for creating web pages that anyone can use. Open standards have been a cornerstone of the web’s success. Closed Worlds contrast with open standards. They are platforms with technologies that restrict access and usage. For example, Apple’s iOS ecosystem is relatively closed, as it tightly controls which apps can be installed on its devices. Closed worlds can limit innovation and competition.

The Internet is the underlying network connecting devices globally. It’s the physical structure that allows data to be transmitted between devices. The Web, on the other hand, is an application layer built on top of the Internet, primarily for accessing and sharing information using protocols like HTTP. It consists of a vast collection of interconnected documents and resources that are accessible via hyperlinks. In my experience, the web has been my primary interface for accessing information, communicating, and interacting with a vast array of online services. The internet, as the underlying network, enables all of these capabilities, including the transmission of data that makes the web possible.

The author’s vision for the future of the web, as of the time of writing, placed significant emphasis on open data, social machines, web science, and freely available bandwidth. This vision aspired to create a web where data is more dynamic and readily accessible. Dazhongdianping and Meituan serve as prime examples of platforms where numerous individuals share their reviews and ratings of restaurants, which influence the decisions made by potential patrons. These platforms have gained significant popularity.

Today’s web still incorporates some of these ideals. However, issues like “fake news” and the consolidation of power by a few tech giants have emerged. These challenges threaten the original vision. Many individuals may not have as much control over their data and content as the author had hoped.

In summary, the web has evolved, and achieving the full realization of the author’s vision remains a work in progress.