diff --git a/Documentation2.md b/Documentation2.md index 28f94fa..a4f7d8f 100644 --- a/Documentation2.md +++ b/Documentation2.md @@ -1,19 +1,43 @@ -# Name: +# Name:void merryChristmas ## Examples: -Insert examples here. +void merryChristmas() { + background(0); + fill(255, 0, 0); + textSize(50); + text("Merry Christmas!", mouseX, mouseY); + if (mouseX>width/2-100) { + return; + } + fill(0, 255, 0); + text("Feliz Navidad!", mouseX, mouseY+100); ## Description: -Insert description here +the mouse will control where the user sees both Merry Christmas and Feliz Navidad +on the screen. however, when the mouse's X position is greater than half the width of the +screen, then the "Feliz Navidad" goes away. ## Syntax: -Demonstrate syntax here +void datatype(){ + background(int, int); + fill(r,g,b); + textSize(int); + text("text", x,y); + if(something){ + return(); +} + +fill(r,g,b); +text("text", x,y); +} ##Parameters: Name and describe parameters here +none -##Returns: -What type of data does it return? +##Returns:it gets rid of the "Feliz Navidad" after the mouse's X location +is greater than half the width +no numerical data is returned ##Other notes: Anything else? diff --git a/functionsChallenge/functionsChallenge.pde b/functionsChallenge/functionsChallenge.pde new file mode 100644 index 0000000..5256e04 --- /dev/null +++ b/functionsChallenge/functionsChallenge.pde @@ -0,0 +1,32 @@ +void setup() {//runs once + size(600, 600); +} + +void draw() {//runs in a loop + println(square(25)); //the program will find the square root of a number + merryChristmas();//the function will run in a loop + println(quadratic(1, 5, 6));//the answers will be printed +} + +float square(int num) {//initialize the function + float result=sqrt(num); //to find the square root of the number + return result;//returns the result, the square root +} +float[] quadratic(float a, float b, float c) {//function is float, because it will return a value + float[] answers = new float[2];//the quadratic formula looks for two answers + answers[0]=(-b + sqrt( b*b - 4*a*c)) / (2*a);//the first array will look for the first x + answers[1]=(-b - sqrt( b*b - 4*a*c)) / (2*a);//will calculate the second x + return answers;//will then give both x's +} + +void merryChristmas() {//the function, merryChristmas, is initialized + background(0); + fill(255, 0, 0);//the color of the first line of text + textSize(50); + text("Merry Christmas!", mouseX, mouseY);//what the first line of text will say + if (mouseX>width/2-100) {//when the x position of the mouse is greater than 1/2 the width, then the second line will disappear + return;//will return to the original first line of text depending where the mouse is positioned + } + fill(0, 255, 0); + text("Feliz Navidad!", mouseX, mouseY+100);//the second line of text, which disappears according to the position of the mouse +} \ No newline at end of file diff --git a/merryChristmas.txt b/merryChristmas.txt new file mode 100644 index 0000000..a4f7d8f --- /dev/null +++ b/merryChristmas.txt @@ -0,0 +1,43 @@ +# Name:void merryChristmas + +## Examples: +void merryChristmas() { + background(0); + fill(255, 0, 0); + textSize(50); + text("Merry Christmas!", mouseX, mouseY); + if (mouseX>width/2-100) { + return; + } + fill(0, 255, 0); + text("Feliz Navidad!", mouseX, mouseY+100); + +## Description: +the mouse will control where the user sees both Merry Christmas and Feliz Navidad +on the screen. however, when the mouse's X position is greater than half the width of the +screen, then the "Feliz Navidad" goes away. + +## Syntax: +void datatype(){ + background(int, int); + fill(r,g,b); + textSize(int); + text("text", x,y); + if(something){ + return(); +} + +fill(r,g,b); +text("text", x,y); +} + +##Parameters: +Name and describe parameters here +none + +##Returns:it gets rid of the "Feliz Navidad" after the mouse's X location +is greater than half the width +no numerical data is returned + +##Other notes: +Anything else? diff --git a/quadratic.txt b/quadratic.txt new file mode 100644 index 0000000..fa14cf8 --- /dev/null +++ b/quadratic.txt @@ -0,0 +1,30 @@ +# Name: float [] quadratic + +## Examples: +float[] quadratic(float a, float b, float c) { + float[] answers = new float[2]; + answers[0]=(-b + sqrt( b*b - 4*a*c)) / (2*a); + answers[1]=(-b - sqrt( b*b - 4*a*c)) / (2*a); + return answers; + +## Description: +the function was created to calculate the zeros of the equation, chosen by user, by using the +quadratic formula. it is an array, since the formula will provide two answers. +the function is a float, since it will return a value, and then set up with three float parameters + +## Syntax: +datatype[]var( float var, float var, float var){ + datatype[]var= new datatype[n]; + var[n]=value; + return var; + +##Parameters: +float a,b,c= according to equation chosen by user in void draw +these are the coefficients in the quadratic formula, and also serve as the variables +in the function + +##Returns: +the zeros of the equation (value) + +##Other notes: +Anything else? diff --git a/square().txt b/square().txt new file mode 100644 index 0000000..4dc6fee --- /dev/null +++ b/square().txt @@ -0,0 +1,28 @@ +# Name: Desiree Armas + +## Examples: +variables +num=25; +the program will then find the square root of 25 + +## Description: +the user gets to choose a number +the program will then find the sqaure root of that number +( in order for the syntax to be user-friendly, +I inserted a variable , num and result, instead of an actual value) + +## Syntax: +void draw(){ +println(square(25));//the user chose this number, represented in the below code (num) +float square(int num) { + float result=sqrt(num);// this finds the square root of the number, represented by (result) + return result;//returns the result + +##Parameters: +integers( int num) + +##Returns: +the square root of a chosen number + +##Other notes: +Anything else? diff --git a/square()function.txt b/square()function.txt new file mode 100644 index 0000000..d811921 --- /dev/null +++ b/square()function.txt @@ -0,0 +1,28 @@ +# Name: float square + +## Examples: +variables +num=25; +the program will then find the square root of 25 + +## Description: +the user gets to choose a number +the program will then find the sqaure root of that number +( in order for the syntax to be user-friendly, +I inserted a variable , num and result, instead of an actual value) + +## Syntax: +void draw(){ +println(square(25));//the user chose this number, represented in the below code (num) +float square(int num) { + float result=sqrt(num);// this finds the square root of the number, represented by (result) + return result;//returns the result + +##Parameters: +integers( int num) + +##Returns: +the square root of a chosen number + +##Other notes: +Anything else?