# Help with complex homework(Solved)

**URL:** https://discourse.processing.org/t/help-with-complex-homework-solved/32837
**Category:** Coding Questions
**Tags:** homework
**Created:** [October 14, 2021, 10:03pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837 "2021-10-14T22:03:03Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:03pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/1 "2021-10-14T22:03:04Z")

</div>

Hi everyone, I would really appreciate the help trying to figure out this code. I have been working at it for hours and I haven’t gotten any progress on it at all. I hope that you are able to help in any kind of way. The image below is supposed to be the outcome of the code. Thank you

> void setup()  
> {  
> size(400, 400);  
> noLoop();  
> }
> 
> void draw()  
> {  
> background(255);  
> noStroke();
> 
> for(int i=0; i\<72; i++)  
> {  
> DrawFlower( \_ , \_ , \_ , \_ , \_ );  
> }  
> }
> 
> void DrawFlower(float x, float y, float s, float angle, float alpha)  
> {  
> fill(0, \_ );  
> pushMatrix();  
> translate( \_ , \_ );  
> rotate( \_ );  
> scale( \_ , \_ );
> 
> beginShape();  
> vertex(0, 0);  
> bezierVertex(0, 0, 0, -54, 30, -72);  
> bezierVertex(54, -90, 72, -117, 72, -144);  
> bezierVertex(72, -144, 96, -96, 78, -72);  
> bezierVertex(66, -44, 0, -36, 0, 0);  
> endShape();  
> popMatrix();  
> }

![question help](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a3ff81f17a7d69d2222e8fe062371453fd865bc8.png)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:10pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/2 "2021-10-14T22:10:59Z")

</div>

thank you!

this code is not runnable

Did you write the code?

I wonder about the \_ . Did you put them there or your teacher?

What have you tried, where are you stuck?

**Remark**

Some things should be clear, for example: rotate( … );

take a guess, what has to be written there?

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:16pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/3 "2021-10-14T22:16:35Z")

</div>

No, I didn’t write the code it was given to me like that from my teacher. I put the underscores there to signify the empty space. I have tried input the x,y, s, angle, and alpha to the translate, rotate, and scale but it didn’t work and I am confused about the DrawFlower(); part on what to put in there.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:19pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/4 "2021-10-14T22:19:05Z")

</div>

> [@Onipunch777](#):
>
> void DrawFlower(float x, float y, float s, float angle, float alpha)

Do you know the purpose of a function?

As you can see, the function name is DrawFlower and some numbers are passed to it (which are then stored in variables (that are known within the function))

- x,y signifies the location - use with translate
- s signifies the scale
- angle the angle of the leaf (between 0 and 2 PI)
- and alpha the degree of opaqueness

this is for:

> [@Onipunch777](#):
>
> I have tried input the x,y, s, angle, and alpha to the translate, rotate, and scale but it didn’t work

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:20pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/5 "2021-10-14T22:20:01Z")

</div>

son now you can fill in

```auto
translate( _ , _ );
rotate( _ );
scale( _ , _ );

```

with the variables from the header of the function: x,y and so on

can you show me?

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:22pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/6 "2021-10-14T22:22:22Z")

</div>

translate( x , y );  
rotate( angle );  
scale( s , alpha);

would this be wrtie

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:22pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/7 "2021-10-14T22:22:38Z")

</div>

> [@Onipunch777](#):
>
> I am confused about the DrawFlower(); part on what to put in there.

here you mean the line  
` DrawFlower( _ , _ , _ , _ , _ );`  
in the function draw() where we actually call (use) the function DrawFlower.

- Now, we want to pass the parameters to the function that the function wants to hear.

- (what we write here: ` DrawFlower( _ , _ , _ , _ , _ );` must match this: `void DrawFlower(float x, float y, float s, float angle, float alpha)` )

We start with (check definition of function DrawFlower(float x, float y, …) ) x,y, which is the position, so we want to pass the position. Let’s use the center of the screen.

Ideas?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:23pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/8 "2021-10-14T22:23:39Z")

</div>

WELL DONE!!

almost correct

except

> [@Onipunch777](#):
>
> scale( s , alpha);

we want scale( s , s);

the alpha is for opaqueness of the color so use fill(0, alpha ); please

**so your function is finished now.**

Now look up to my previous post as how to call the function from draw() please

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:27pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/9 "2021-10-14T22:27:48Z")

</div>

would it be width/2 and height/2 or would it be something completely different?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:29pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/10 "2021-10-14T22:29:14Z")

</div>

That’s nice!

Excellent.

Next is ? s.

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:30pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/11 "2021-10-14T22:30:28Z")

</div>

Would it be between 0.5 and 1 right or would it be just s?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:31pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/12 "2021-10-14T22:31:33Z")

</div>

that’s the scale (size)

let’s go for 1 first.

you can replace it with a random number like random(0.5,1) later

**Next is ?**

---

<div class="post-metadata">

### Author: ![hotfooted](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hotfooted/32/3670_2.png) [@hotfooted](https://discourse.processing.org/u/hotfooted)
#### Post date: [October 14, 2021, 10:32pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/13 "2021-10-14T22:32:05Z")

</div>

that was a great way to handle a homework question @Chrisir

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:33pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/14 "2021-10-14T22:33:14Z")

</div>

the next would be float angle with the DrawFlower

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:34pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/15 "2021-10-14T22:34:09Z")

</div>

that’s right.

That angle should **increase** with every step.

Let’s put `i` for a test

**i** is our variable from the for-loop, so **i** gets bigger by one every time

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:36pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/16 "2021-10-14T22:36:18Z")

</div>

so all would be left is float alpha

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:36pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/17 "2021-10-14T22:36:27Z")

</div>

What’s next?

`alpha`

which is how opaque our color is.

alpha is correct

let’s say 60

* * *

**Now**

try run your code

Does it run?

you need a running code to improve the graphic

I suggest we take care of the angle first.

That’s probably very wrong. Ideas?

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:39pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/18 "2021-10-14T22:39:42Z")

</div>

sorry I was screenshotting the work it works and I am really thankful for you for helping

 ![so](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d4b7a91b3a53bb097bae3bbcafbcc53126991873.png)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 14, 2021, 10:41pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/19 "2021-10-14T22:41:04Z")

</div>

WELL DONE!!

Now, we have differences to the initial graphic.

you can use some random.

Do you have ideas where we want to use random?

---

<div class="post-metadata">

### Author: ![Onipunch777](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/onipunch777/32/14715_2.png) [@Onipunch777](https://discourse.processing.org/u/Onipunch777)
#### Post date: [October 14, 2021, 10:41pm UTC](https://discourse.processing.org/t/help-with-complex-homework-solved/32837/20 "2021-10-14T22:41:51Z")

</div>

we could use it in scale

[Next page](https://discourse.processing.org/t/help-with-complex-homework-solved/32837.md?page=2)
