Project Title: A flag that flutters
Link: https://editor.p5js.org/Lisa-HuangZijin/sketches/8LSNeb8fp
Brief Description and Concept: Since it is a project-oriented project, I plan to imitate swaying with the wind. To meet the requirement of interaction, I applied mouse’s position and its clicking and releasing.
Coding part: Since my particles don’t need to be random generated, I didn’t use array here for a simple task. But I believe I can apply it somewhere for a better visualization.
As the picture indicates, I tried to let it move on a ellipse track and then let the ellipse move as well. When I use different parameters for frameCount in x and y position, I found it moved more vividly. So I kept going.
One of the challenging parts is that I want to let the ellipses have a sense of convergence when the mouse is clicked, so I apply the distance function and mousePressed as well.
- What is Object-Oriented Programming (OOP), a Class and an Instance of the Class?
Object-Oriented Programming seems to be a program that focuses on modeling real-world objects.
A class is template to define the behaviors of a particular object. It’s like a blueprint that defines the properties and methods that objects of that class will have.
An instance of a class is an individual object created from the blueprint provided by the class.
- Discuss the effectiveness of OOP. When is OOP useful? In what way can it be utilized?
It helps me organize my code and make it tidy. When I need to modify something, it is easy for me f=to find the right place. It could be used to create the real object and build framework for object.
- Describe the objects you have created. What properties and methods were implemented? What kind of behaviors did you create by manipulating them?
In my mini project, the object created was a Particle class, which had properties such as x, y, R, G, B, and methods such as update() and display(). The behavior of the Particle class was to draw a colorful pattern of circles on the screen. By manipulating the properties and methods of the Particle class, I am able to create different patterns and effects on the screen.
For example, by changing the values of R, G, and B properties,I’m able to adjust the color of the circles based on their distance from the center of the screen. By manipulating the values of mouseX and mouseY, I’m able to create an effect where the color of the circles changed based on the position of the mouse. These behaviors were made possible by the object-oriented approach of the Particle class, which allowed us to encapsulate data and behavior in a reusable and modular way.