1.2: control.pde

// This Processing program creates a little animation machine
// with controls that you can customize.
// First, we need to “declare” a few variables of 3 different types.
int bDia, cDia, mvX, mvY;
float cX, cY, clickX, clickY;
color cCol;

void setup() {
size(201, 400); // Create a program window 201 pixels wide and 400 pixels high.
stroke(127); // Set the color for the outlines of our shapes.
bDia = 20; // Set the diameter of our circular control buttons.
cDia = 20; // Set the diameter of the “action circle” we will control.
cX = 100; // Set the starting horizontal position of the action circle.
cY = 300; // Set the starting vertical position of the action circle.
cCol = color(255, 255, 255); // Set the starting color of the action circle.
mvX = 0; // Set the horizontal movement of the action circle.
mvY = 0; // Set the vertical movement of the action circle.
}

void draw() {
// These first 4 lines let you use math coordinates instead of computer coordinates.
scale(1, -1);
translate(0, -height);
clickX = mouseX;
clickY = height – mouseY;

fill(61, 73, 16); // Color the screen green
rect(0, 200, 200, 200); // Draw the square “action screen”.

ellipse(100, 60, bDia, bDia); // Draw the top button.
ellipse(100, 100, bDia, bDia); // Draw the middle button.
ellipse(100, 140, bDia, bDia); // Draw the bottom button.
ellipse(60, 100, bDia, bDia); // Draw the left button.
ellipse(140, 100, bDia, bDia); // Draw the right button.

fill(cCol); // Set the color for the action circle.

cX = cX + mvX; // Set the horizontal position of the action circle.
cY = cY + mvY; // Set the vertical position of the action circle.

// The 2 “print lines” below will display at the bottom of this window.
// They will let us check the coordinates of the program window.
println(“X =”, clickX);
println(“Y =”, clickY);

ellipse(cX, cY, cDia, cDia); // Draw the action circle.
}

void mousePressed() {
//Check if the user clicked the middle button.
if (dist(clickX, clickY, 100, 100) < bDia/2) {
cCol = color(237, 168, 23);
// If so, turn the action circle yellow.
}

//Check if the user clicked the top button.
else if (dist(clickX, clickY, 100, 140) < bDia/2) {
mvY = 1;
//If so, make the action circle move up.
}

//If the user pressed the bottom button
else if (dist(clickX, clickY, 100, 60) <bDia/2) {
mvY = -1;
//If so, make the action circle move down.
}

//Check if the user clicked the left button.
else if (dist(clickX, clickY, 60, 100) < bDia/2) {
mvX = -1;
//If so, make the action circle move left.
}

//Check if the user clicked the right button.
else if (dist(clickX, clickY, 140, 100) < bDia/2) {
mvX = 1;
//If so, make the action circle move right.
}

}

Advertisements

DISCOVER (DATA)

When it comes to music, people favor different elements of a song which makes them  have a certain feeling of that song. Which is exactly why my class is creating a program which recommends people a song that they like based off of the elements of a song that they like.

For instance, I like the song Nights by Frank Ocean because of the catchy tempo and bass of the song. Personally I think the tempo, bass, and also how catchy of a song makes it good music.

 

DEFINE (DATA)

A SONG IN DATA

My class defined a song by using the following components:

Title

A string given by the user (What is the title of the song?)

Performer

A string given by the user (Who is the performer of the song?)

Genre

A restricted string that provides genres that you can only pick from. (What is the genre of the song?)

  1. Blues
  2. Classical
  3. Country
  4. Electronic
  5. Folk
  6. Hip Hop
  7. Jazz
  8. Latin
  9. Pop
  10. Reggae
  11. Religious
  12. Rock
  13. RnB
  14. World
  15. Other

Sub genre

A string given by the user (What is the sub genre of the song?)

Primary Instrument

A string given by the user (What is the main instrument in the song?)

Lyrics

An integer (On a scale from 1-10 how important are the lyrics to the song?)

Bass

An integer (On a scale from 1-10 how strong is the bass in the song?)

Tempo

An integer (On a scale from 1-10 how fast is the song?)

Feeling

A restricted string providing options for user to pick how the song makes them feel.

These options are:

  1. Happy/Joyful
  2. Sad
  3. Romantic
  4. Angry
  5. Chill
  6. Motivating
  7. Compassionate
  8. Humorous
  9. Enlightening
  10. Confused
  11. Passionate
  12. Hype
  13. Grace

 

Example of song data

Title                                                                                Performer                                     Genre

Violet Hole rock punk guitar 4 6 4 sad
Day ‘N’ Nite (nightmare) Kid Cudi hip hop alternative hip hop drum machine 4 4 5 chill
Slide Calvin Harris electronic synthpop piano 5 5 7 joy
DYWM NAO electronic synthpop guitar 5 5 8 romantic
Super Rich Kids Frank Ocean RnB neo soul piano 5 7 9 chill

bullsEyes.py

Version 1

v1

I started out bulls eye with creating a green circle, centered in a window. I used the circle function to create the circle.

v1P

Version 2

v2

In this version, I created a custom function to create a circle, I used arguments in my function that I needed to create a circle.

v2P

Version 3

v3

In this version, I had created two custom functions. One that creates a large circle and one that creates a smaller circle. I later on realized that I did not need both of these functions, only one. Because with custom functions, other people can import them into their files and use them when they are not so general and specifically only make that certain graphic in this case.

v3P

Version 4

v4

In this version, I had deleted the small circle custom function and I created my circle function to be more general where you can place your own colors in the arguments to generate a different color. I had specific colors that I used to create the circle. I also created a custom function that draws the rings in the bulls eye.

v4P

Version 5

v5

In this version, I imported the random module to make my bulls eye move horizontally left and right and also vertically up and down. Every time when my program is ran it moves randomly horizontal and vertically.

v5P

Version 6

v6

In this version, I made the number of rings change randomly. I had it run from a range of 4 being the smallest amount of rings and 25 being the largest amount of rings.

v6P

Version 7

v7

In this version, I had created a custom function that generates random colors. For this I had to define the smallest and largest integers I wanted to use for my colors using RGB. The smallest was 50 and the largest was 200. I also had added thickness for how thick I wanted the rings to be.

v7P

Version 8

v8

In this version I had created multiple bulls eyes using my custom function for rings and using a for loop.

v8P

Version 9

v9

In this version, I had just changed the colors and I added more bulls eyes. I also changed the highest amount of rings I can have.

v9P