From 954c7d9b8420d52de5e556b6f4f6568271e6f0b0 Mon Sep 17 00:00:00 2001 From: mliterate Date: Wed, 2 Dec 2015 14:50:29 -0500 Subject: [PATCH 1/3] add my functions --- VoidFunctions/VoidFunctions.pde | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..d2e06ab 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,45 @@ +void setup(){ + + size(500,500); + noStroke(); + + + +} + + + +void draw(){ + + mousecircle(0,255,0); +blueSquare(); + blackcirclesquare(); + } + + + + + + + +void mousecircle(float x, float y, float z){ +fill(x,y,z); + ellipse(mouseX,mouseY,30,30); + +} + +void blueSquare(){ +rectMode(CENTER); +fill(0,0,255); +rect(width/2,height/2,50,50); + + +} +void blackcirclesquare(){ +fill(0); +rect(random(width),random(height),random(5,50),random(5,50)); +ellipse(random(width),random(height),random(5,50),random(5,50)); + + +} \ No newline at end of file From a33e3345bf44f32f57e637a1c194dbd725a71d19 Mon Sep 17 00:00:00 2001 From: mliterate Date: Fri, 4 Dec 2015 13:55:53 -0500 Subject: [PATCH 2/3] add comments --- VoidFunctions/VoidFunctions.pde | 39 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index d2e06ab..deed088 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1,7 +1,7 @@ void setup(){ - size(500,500); - noStroke(); + size(500,500); //set size + noStroke(); //remove stroke @@ -12,9 +12,9 @@ void setup(){ void draw(){ - mousecircle(0,255,0); -blueSquare(); - blackcirclesquare(); + mousecircle(0,255,255); //use the mousecircle function to draw a green circle at the mouse +blueSquare(); //use the bluesquare function to draw a blue circle at the center + blackcirclesquare(); //use he blackcirclesquare function to draw black circle and square } @@ -23,23 +23,26 @@ blueSquare(); -void mousecircle(float x, float y, float z){ -fill(x,y,z); - ellipse(mouseX,mouseY,30,30); +void mousecircle(float r, float g, float b){ //name the function and give it three values that user can define -} - -void blueSquare(){ -rectMode(CENTER); -fill(0,0,255); -rect(width/2,height/2,50,50); +fill(r,g,b); //fill the colors with variables to be defined + ellipse(mouseX,mouseY,30,30); //draw a circle at the mouse and 30 diameter } -void blackcirclesquare(){ -fill(0); -rect(random(width),random(height),random(5,50),random(5,50)); -ellipse(random(width),random(height),random(5,50),random(5,50)); + +void blueSquare(){ //name the function +rectMode(CENTER); //change the rectangle mode to center +fill(0,0,255); //fill blue +rect(width/2,height/2,50,50); //draw the rectangle +} +void blackcirclesquare(){ //name the function +fill(0); //fill black +rect(random(width),random(height),random(5,50),random(5,50)); //draw random rectangles between the canvas between the size 5 and 50 +ellipse(random(width),random(height),random(5,50),random(5,50)); //draw random circles between the canvas between the size 5 and 50 +if(mousePressed){ //if mouse is pressed set the back ground to white and erase the other things + background(255); //redraw the background +} } \ No newline at end of file From f22cbe02719fb8eaf2809c40ab3c0525682cf068 Mon Sep 17 00:00:00 2001 From: mliterate Date: Fri, 4 Dec 2015 14:48:16 -0500 Subject: [PATCH 3/3] create a meter to centimeter function --- ReturningValues/ReturningValues.pde | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..034fd0c 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,18 @@ +void setup() { + +} + +void draw() { +println(meterTocenti(10)); + +} + + + +float meterTocenti(float meter){ + float centi = meter/100; + return centi; + + +} \ No newline at end of file