# Cardioid drawer in Python mode

**URL:** <https://discourse.processing.org/t/cardioid-drawer-in-python-mode/26544>\
**Category:** Gallery\
**Created:** [December 27, 2020, 11:23pm UTC](https://discourse.processing.org/t/cardioid-drawer-in-python-mode/26544 "2020-12-27T23:23:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 27, 2020, 11:23pm UTC](https://discourse.processing.org/t/cardioid-drawer-in-python-mode/26544/1 "2020-12-27T23:23:14Z")

</div>

```auto
n = 200
m = 2
r = 300
def setup():
    size(600,600)
def draw():
    background(0)
    stroke(255)
    for i in range(n):
        a = TWO_PI/n
        line(width/2 + cos(a*i)*r, height/2 + sin(a*i)*r, width/2 + cos(a*i*m)*r, height/2 + sin(a*i*m)*r)
        line(width/2 + cos(a*i)*r, height/2 + sin(a*i)*r, width/2 + cos(a*(i+1))*r, height/2 + sin(a*(i+1))*r)

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/ba2bdb4b0310ff1f68ae00e012d277634a65d86e.png)

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 27, 2020, 11:24pm UTC](https://discourse.processing.org/t/cardioid-drawer-in-python-mode/26544/2 "2020-12-27T23:24:44Z")

</div>

I guess you can get rid of `def setup` and `def draw` and make it a static program

edit: here

```auto
n = 200
m = 2
r = 300
size(600,600)
background(0)
stroke(255)
for i in range(n):
    a = TWO_PI/n
    line(width/2 + cos(a*i)*r, height/2 + sin(a*i)*r, width/2 + cos(a*i*m)*r, height/2 + sin(a*i*m)*r)
    line(width/2 + cos(a*i)*r, height/2 + sin(a*i)*r, width/2 + cos(a*(i+1))*r, height/2 + sin(a*(i+1))*r)

```
