From bf1e55c550e7e6e4b4f9350a4fd3e26752d8b0f3 Mon Sep 17 00:00:00 2001 From: nafahmed Date: Tue, 1 Dec 2015 12:43:43 -0500 Subject: [PATCH 1/5] void functions for square, circle, and image --- VoidFunctions/VoidFunctions.pde | 35 ++++++++++++++++++++++++++++++++ VoidFunctions/data/asoue.jpg | Bin 0 -> 2115 bytes 2 files changed, 35 insertions(+) create mode 100644 VoidFunctions/data/asoue.jpg diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..3fd2839 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,36 @@ +float a, b, c; +PImage asoue; +void setup() { + size(800, 600); + a=0; + b=0; + c=0; + asoue = loadImage("asoue.jpg"); +} +void draw() { + background(255); + drawabluesquare(); + drawacircle(); + drawanimage(mouseX,mouseY); +} + +void drawabluesquare() { + fill(0, 0, 255); + rect(375, 275, 50, 50); +} + +void drawacircle() { + fill(a, b, c); + ellipse(mouseX, mouseY, 30, 30); + if (mousePressed) { + a=random(255); + b=random(255); + c=random(255); + } +} + +void drawanimage(float x, float y) { + + image(asoue, x,y); +} \ No newline at end of file diff --git a/VoidFunctions/data/asoue.jpg b/VoidFunctions/data/asoue.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a96d79534b2013a822790f4f763b682e4bcd4f3d GIT binary patch literal 2115 zcmb7Dc{tPy7yiwRbu42TWg9dz7({l)z7&R}Y?XB^AQ+OUq>`oZb(ujV5_zm+ zPYjZwjBPC0vc#04g^Rg$zdyd`{`tMVu$AsF0wL6bvS%uOO$O|9^wi3BdUPcfbh(LIGen2m%Ljx&i55 z8M%Ka{U0D)+&sMC-%ULc01Sdaz+7AqUhaQpKwt>K1?Lt$qG`c%#y3(7rB#GLC-I6~ zCTG^X#W=m3-_-uKhxoVPZ|UDG{9iWzuq;3j0{WE(0td{1>EPltaGGjv>^;e8QiT?N z1Iv%G&7|14oRB=)3qZ-)J+pF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P742N3>eZEf?KEw?yw+1<&D}-fm89PFNA*zH z@Asv}pBrw;sNlhyJgZ0=4P!jUkz+BC)Q7hQD6JVbIZ?R98x{ibPhW3&pU|cD&k=yz3Vi4(Q>J(LeGajD5GF}z>^wM_S*cih;&rBK-78mr; zl_inCjiIiB$`!`9*Pqx{PS3OuJ5!=Sk_?ZsGIu_QQ?{`_F#ILMnx=a!%fscq**{jc zd6BBRO)Va()m<0Yj>LH}TuHXIl)bquVRMG|6i$jsrcYUld1`3(!&ZO#cQKc?WNj_}#qRCA@878^* zzK#3V_rz#S?fFyYu2IgU=*H04A7OH9?w9k&9RI>KOE$X2T4t-{rHMyoS$j}TO*Cv8 zUSLg%)3DI{US$-Z)DMk_m6DmZea5BMBOECG1@*G0sojAG|%vr ziJD}Y<=*$)aNbRBb!=qE(!}_1jEkUP_7d13GmB_Yt^z4qF zwP7tMVlrJ?d!Z59H$5{?+kcTGx_qy2Pq-PfGfe&vP zk$ecSy_(Xyp_|{e%6(7 Date: Tue, 1 Dec 2015 13:12:25 -0500 Subject: [PATCH 2/5] created fill function --- VoidFunctions/VoidFunctions.pde | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 3fd2839..8beef2f 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -2,9 +2,7 @@ float a, b, c; PImage asoue; void setup() { size(800, 600); - a=0; - b=0; - c=0; + asoue = loadImage("asoue.jpg"); } @@ -21,16 +19,17 @@ void drawabluesquare() { } void drawacircle() { - fill(a, b, c); - ellipse(mouseX, mouseY, 30, 30); - if (mousePressed) { - a=random(255); - b=random(255); - c=random(255); - } + setfill(40,195,255); + ellipse(mouseX, mouseY, 30, 30); + + } void drawanimage(float x, float y) { image(asoue, x,y); +} + +void setfill(float r, float g, float b){ + fill(r,g,b); } \ No newline at end of file From d746b649c24cc6e092bc6a7d8106d9761deab81a Mon Sep 17 00:00:00 2001 From: nafahmed Date: Tue, 1 Dec 2015 13:22:13 -0500 Subject: [PATCH 3/5] returning the answer --- ReturningValues/ReturningValues.pde | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..7ae7052 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,18 @@ + + +void setup() { + + + +} + +void draw() { +ellipse(mouseX,mouseY,addnumberstogether(20,22),addnumberstogether(20,22)); + +} + +float addnumberstogether(float a, float b){ + float result = a+b; +return result; +} \ No newline at end of file From 8173197fa4e66a0daf751613a0315e68025f34d3 Mon Sep 17 00:00:00 2001 From: nafahmed Date: Thu, 3 Dec 2015 12:56:21 -0500 Subject: [PATCH 4/5] pythagorean theorem code in the comments, adding three values is uncommented code --- ReturningValues/ReturningValues.pde | 36 +++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 7ae7052..c181f0b 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1,18 +1,40 @@ +//void setup(){ + +//} -void setup() { +//void draw(){ +//println(hypot(5,12)); +//} + +//float hypot(float a, float b){ //pyhthagorean theorem +//float c = sqrt(sq(a) + sq(b)); +//return c; // +//} + +/************************** +c = square root of (a squared +b squared) +sqrt(num); +sq(num); +**********************/ -} -void draw() { -ellipse(mouseX,mouseY,addnumberstogether(20,22),addnumberstogether(20,22)); +//add three values together + +void setup(){ + + +} +void draw(){ + + println(numbers(1,2,3)); } -float addnumberstogether(float a, float b){ - float result = a+b; -return result; +float numbers(float a, float b, float c){ + float d = a+b+c; + return d; } \ No newline at end of file From d96a5dba8863eb19c9a7862c06ec1a13e912013b Mon Sep 17 00:00:00 2001 From: nafahmed Date: Thu, 3 Dec 2015 13:11:07 -0500 Subject: [PATCH 5/5] annotated code --- ReturningValues/ReturningValues.pde | 36 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index c181f0b..d36d735 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -2,28 +2,36 @@ //void setup(){ -//} -//void draw(){ +/************************************************* +} -//println(hypot(5,12)); -//} +//pythagorean theorem -//float hypot(float a, float b){ //pyhthagorean theorem -//float c = sqrt(sq(a) + sq(b)); -//return c; // -//} +void draw(){ -/************************** -c = square root of (a squared +b squared) -sqrt(num); -sq(num); -**********************/ + println(hypot(5,12)); //write a new line each frame of the hypot function with values 5 and 12 for a and b +} -//add three values together +float hypot(float a, float b){ //float new function with variables a and b +float c = sqrt(sq(a) + sq(b)); //pythagorean theorem +return c; //repeat +} + + +//c = square root of (a squared +b squared) +//sqrt(num); +//sq(num); + + + +**********************************/ + + +//add three values together void setup(){