# Genuary2023_Moire

### **The prompt for Genuary 2023 Day 23 is**

## Moire

* Overlaying a multitude of Moire Circles and other shapes
    
* Sound is coded in SonicPi using the distance equation
    

<iframe width="560" height="315" src="https://www.youtube.com/embed/dLd2ANRProk"></iframe>

```plaintext
Overlaying
As the circle prowl
As their diameters growl
And their circumferences howl
For they are not staying
As the day turns in
```

### **SonicPI Code**

```ruby
def distance(x1,y1,x2,y2)
  distance = Math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
  puts distance
  distance
end


i = 0

live_loop :distancing do
  
 #a and b are line 1 and line 2
#X and Y are the coordinates
  Xa = [5,7,9,12,4,1]
  Ya = [2,3,5,6,1,3]
  Xb = [0,4,5,2,1,7]
  Yb = [3,2,4,5,0,8]
  
  x = distance(Xa[i],Xb[i],Ya[i],Yb[i])
  y = distance(Xa[dice(i)],Xb[dice(i)],Ya[dice(i)],Yb[dice(i)])
  
  with_fx :flanger, amp: dice(2) do
    with_fx :ping_pong, mix: rrand(0.3,0.6) do
      use_synth :hollow
      play (x * y)/2, sustain: dice(4)
      play_pattern_timed chord([:c3,:E3].choose, :m7), x/y
    end
  end
  
  if i >= Xa.length - 1
    i = 0
  end
  
  i+= 1
  
  sleep [0.25,0.5,1,2,4].choose
end




j = 0

live_loop :distancing2 do
  
  #points C and D
  Xc = [dice(3)+3,dice(6),dice(5),dice(10)]
  Yc = [dice(2),(dice(5)-1).abs,dice(7),dice(10)+1]
  Xd = [dice(5),dice(4),dice(5),(dice(10)-1).abs]
  Yd = [dice(9),dice(7),dice(9),dice(10)]
  
  x = distance(Xc[j],Xd[j],Yc[j],Yd[j])
  y = distance(Xc[dice(j)],Xd[dice(j)],Yc[dice(j)],Yd[dice(j)])
  
  with_fx :pitch_shift, mix: 0.35, amp: dice(2) do
    with_fx :ping_pong, mix: rrand(0.3,0.6) do
      use_synth :hollow
      play (x * y)/1.5, attack: dice(4)
      play_pattern_timed chord([:c2,:e3,:a4,:g2].choose, :m7), y/x
    end
  end
  
  if j >= Xa.length - 1
    j = 0
  end
  
  i+= 1
  
  sleep [0.25,0.5,1,2,4].choose
end

```

### **Hydra Code**

```javascript
pattern = () => voronoi(113,5, 5).blend(osc(50,0)).kaleid([200,100,50,10,5,4,3,2].smooth()).scale(()=> (time % 10 + 2)/7)
//
pattern()
  .scrollX(0.1, 0.01).colorama(()=> (time % 10 + 1 )/10).scale([2,1,0.5,1,2,3,4].smooth())
  .diff(pattern().scroll([2,1,0.5,1].smooth()))
.blend(pattern())
  .out()


speed = 0.12525
```
