# Help coding

**URL:** <https://forum.critterandguitari.com/t/help-coding/7282>\
**Category:** EYESY\
**Created:** [April 18, 2021, 8:26pm UTC](https://forum.critterandguitari.com/t/help-coding/7282 "2021-04-18T20:26:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blond12](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@Blond12](https://forum.critterandguitari.com/u/Blond12)\
**Post date:** [April 18, 2021, 8:26pm UTC](https://forum.critterandguitari.com/t/help-coding/7282/1 "2021-04-18T20:26:55Z")

</div>

Hello here is my actual mode coding state :

import os  
import pygame  
import time  
import random  
import math

def setup(screen, etc):  
global last\_point, last\_point1, xr, yr, zehn, y72, x180  
xr = etc.xres  
yr = etc.yres  
last\_point = [xr/4, 0]  
last\_point1 = [xr/4, 0]  
zehn = (200_xr)/1280  
y72 = int((72_yr)/720)  
x180 = (360\*xr)/1280  
pass

def draw(screen, etc):  
global last\_point, last\_point1, zehn, y72, x180, xr,yr  
etc.color\_picker\_bg(etc.knob5)  
linewidth = int(etc.knob1_zehn)+1  
lines = int(y72)  
spacehoriz = (x180_etc.knob2)+10  
spacevert = spacehoriz  
color = etc.color\_picker(etc.knob4)

```
for j in range(0, lines) :
    
    space = j*spacehoriz

    pygame.draw.line(screen, color, (0,space), (xr,space), linewidth)

```

Here is a pics to give a global idea.

 ![IMG_20210418_221427](https://canada1.discourse-cdn.com/flex035/uploads/critterandguitari/original/2X/7/7b5b03df41fd09525eab4186d787736bbab880af.jpeg)

Can someone write me the lines for :

- Add on knob 3 a global rotation of all my lines
- Make that the audio/midi trig activate Knob 1 function (linewidth in this code)
- last question whats the line code to make the trig button stay active when we hold it ? For now when i create a " if " then " else" event , the trig button just fire the action once even if i hold the button he dont hold the action i want when my finger stay pressed

---

<div class="post-metadata">

**Author:** ![DudeTheDev](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@DudeTheDev](https://forum.critterandguitari.com/u/DudeTheDev)\
**Post date:** [April 19, 2021, 5:14pm UTC](https://forum.critterandguitari.com/t/help-coding/7282/2 "2021-04-19T17:14:41Z")

</div>

You may want to check out the code for a similar looking effect, called “T - Rotation Grid - Trails”. It’s in the Etc section on patchstorage, here’s a link: [T - Rotation Grid-Trails | Patchstorage](https://patchstorage.com/t-rotation-grid-trails/)  
It uses the audio to rotate instead of change the line width. But, it probably can be re-worked to accomplish your goals. You’ll want to add a line referencing the “etc.audio\_in” component to get sound interacting with your mode. It looks like the rotation is achieved by using sin and cos methods.  
I recommend downloading that patch, and clearing away irrelevant parts of the code so you can figure out how it makes a single grid rotate. Then, copy that into your mode, but use a knob instead of the audio, and then add a reference to use the audio value in your for loop. Something like:  
def draw(screen, etc):  
#define globals, then all your other code, plus rotate code. Then:

```
for j in range(0, lines) :
    space = j*spacehoriz
    sound=abs(etc.audio_in[j%100]) /300 #may want to change 300 value to something else
    linewidth2 = linewidth + sound
    pygame.draw.line(screen, color, (0,space), (xr,space), linewidth2)

```

Hope that is enough to figure it out!
