# Level - The Geometry of Flowers

**URL:** https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553
**Category:** Adventurer
**Created:** [April 16, 2015, 2:54am UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553 "2015-04-16T02:54:18Z")
**Posts on this page:** 10
**Page:** 2

<div class="post-metadata">

### Author: ![aaronlee3](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aaronlee3/32/3076_2.png) [@aaronlee3](https://discourse.codecombat.com/u/aaronlee3)
#### Post date: [September 28, 2015, 9:13am UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/23 "2015-09-28T09:13:30Z")

</div>

mine does not work.

# You now have the Ring of Flowers! You can do:

# toggleFlowers(True/False) - turns flowers on or off.

# setFlowerColor(“random”) - can also be “pink”, “red”, “blue”, “purple”, “yellow”, or “white”.

# Here are some functions for drawing shapes:

# x, y - center of the shape

# size - size of the shape (radius, side length)

def drawCircle(x, y, size):  
angle = 0  
self.toggleFlowers(False)  
while angle \<= Math.PI \* 2:  
newX = x + (size \* Math.cos(angle))  
newY = y + (size \* Math.sin(angle))  
self.moveXY({“x”: newX, “y”: newY})  
self.toggleFlowers(True)  
angle += 0.2

def drawSquare(x, y, size):  
self.toggleFlowers(False)  
cornerOffset = size / 2  
self.moveXY(x - cornerOffset, y - cornerOffset)  
self.toggleFlowers(True)  
self.moveXY(x + cornerOffset, y - cornerOffset)  
self.moveXY(x + cornerOffset, y + cornerOffset)  
self.moveXY(x - cornerOffset, y + cornerOffset)  
self.moveXY(x - cornerOffset, y - cornerOffset)

redX = {“x”: 28, “y”: 36}  
whiteX = {“x”: 44, “y”: 36}

self.setFlowerColor(“red”)

# Pick a color.

# Draw a size 10 circle) at the redX.

drawCircle({“x”: 28, “y”: 36}, 10)

# Change the color!

self.setFlowerColor(“white”)

# Draw a size 10 square at the whiteX.

drawSquare({“x”: 44, “y”: 36}, 10)

# Now experiment with drawing whatever you want!

it should make a size ten circle and square correctly but it tells me for this statement self.moveXY({“x”: newX, “y”: newY}) that i need to move to a x,y position. please help me

---

<div class="post-metadata">

### Author: ![J\_F\_B\_M](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/j_f_b_m/32/2756_2.png) [@J\_F\_B\_M](https://discourse.codecombat.com/u/J_F_B_M)
#### Post date: [September 29, 2015, 9:22am UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/24 "2015-09-29T09:22:26Z")

</div>

Please post your code with **_radiant, harmonious formatting_**. At the current state it is not easily readable for us, so we can’t help you effectively.

---

<div class="post-metadata">

### Author: ![lighte](https://avatars.discourse-cdn.com/v4/letter/l/76d3ee/32.png) [@lighte](https://discourse.codecombat.com/u/lighte)
#### Post date: [January 6, 2016, 8:22pm UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/25 "2016-01-06T20:22:21Z")

</div>

I believe I may have the same problem as aaronlee3, I’ve typed (i think) the correct code into the spaces suggested, then the pop-up tells me "Line 14:  
moveXY requires 2 numbers as arguments. x is a NaN which is type ‘number’,  
not ‘number’."  
I did not change the original code except to try and fix the problem, then “reloaded” the code anyway, its still not working, thanks for advice in advance. =D

- also using python as code

---

<div class="post-metadata">

### Author: ![UltCombo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ultcombo/32/3822_2.png) [@UltCombo](https://discourse.codecombat.com/u/UltCombo)
#### Post date: [January 6, 2016, 9:39pm UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/26 "2016-01-06T21:39:19Z")

</div>

@lighte Looks like you are passing a NaN value to the `moveXY` function—revise your code to make sure you are not dividing by zero or using non-number variables in your maths. Please post your code if you need further help.

---

<div class="post-metadata">

### Author: ![lighte](https://avatars.discourse-cdn.com/v4/letter/l/76d3ee/32.png) [@lighte](https://discourse.codecombat.com/u/lighte)
#### Post date: [January 6, 2016, 10:32pm UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/27 "2016-01-06T22:32:18Z")

</div>

Thanks for the quick reply! The code that seems to have the issue is the original code,

```python
def drawCircle(x, y, size):
    angle = 0
    self.toggleFlowers(False)
    while angle <= Math.PI * 2:
        newX = x + (size * Math.cos(angle))
        newY = y + (size * Math.sin(angle))
        self.moveXY(newX, newY) < [this is the line that the pop-up message indicates]
        self.toggleFlowers(True)
        angle += 0.2

```

`drawCircle({"x": 28, "y": 36}, 10)` \< this is the code i entered to activate the line,if its my trigger thats the problem, I’m not sure what i need to change.  
Thanks again!

---

<div class="post-metadata">

### Author: ![UltCombo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ultcombo/32/3822_2.png) [@UltCombo](https://discourse.codecombat.com/u/UltCombo)
#### Post date: [January 7, 2016, 1:21am UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/28 "2016-01-07T01:21:38Z")

</div>

@lighte The problem is `drawCircle({"x": 28, "y": 36}, 10)`, it should be `drawCircle(28, 36, 10)`. Sorry for the late reply. 😅

By the way, you can format your code by wrapping it with ```, see the [FAQ](https://discourse.codecombat.com/faq) for details. I’ve done it for you this time.

---

<div class="post-metadata">

### Author: ![charlieduff81](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/charlieduff81/32/4035_2.png) [@charlieduff81](https://discourse.codecombat.com/u/charlieduff81)
#### Post date: [January 7, 2016, 3:13pm UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/29 "2016-01-07T15:13:14Z")

</div>

This level can be beaten by using flags in real time, and while figuring out the full extent of this, you can even walk around the white x and make a square and get the goal for the circle, and you only have to make a shape around both x’s and the level can be completed, you should remove flags from being used in this level.

 ![](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/0/0f5203ee58a82574b5c5d0285c398fd7e2ade795.png)

---

<div class="post-metadata">

### Author: ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)
#### Post date: [July 21, 2018, 11:26pm UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/31 "2018-07-21T23:26:16Z")

</div>

Do you know the peasant is an avid gardener!

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/3/30c5852a29f4e177aa0be068cbb876f769fafc8e.jpg)  
/but peasant.toggleFlowers(True) doesn’t work /

---

<div class="post-metadata">

### Author: ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)
#### Post date: [July 22, 2018, 11:18am UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/32 "2018-07-22T11:18:29Z")

</div>

Wow that’s so cool, does that work on any level when you have the flower ring and a peasant?

---

<div class="post-metadata">

### Author: ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)
#### Post date: [July 22, 2018, 12:52pm UTC](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553/33 "2018-07-22T12:52:35Z")

</div>

I summoned a new peasant in the same level and he/she isn’t a gardener. It will be cool in levels with the flower ring all peasants have this and toggleFlowers ability.

[Previous page](https://discourse.codecombat.com/t/level-the-geometry-of-flowers/3553.md?page=1)
