# WCCChallenge_FireFly

# FireFlyForest

For this week's Creative Code Challenge by **@sableraph: "FireFly”, FireFlyForest**  is coded in ***Hydra, Locomotion & SonicPi.*** It uses these  languages to convey the aspects of fireflies in a forest of their own

## **The Glow of the Fireflies**

* The Colours of the firefly are coded in ***Hydra*** to represent the different possible glows they could emit with some being rarer than others
    
* The Forest coded in ***Locomotion*** goes between being a standalone entity and one being lit up by the fireflies
    
* The ***SonicPi*** composition takes various firefly sounds and merges them into a soundscape 
    
* The Hydra code that is used in tandem with the ***360*** view, is an imagined perspective of what a firefly may see
    

## Poetry

```haskell

FireFlies Roam
FireFlies Glow
FireFlies Light
But not always so bright
Depending on the temperature
Affects the colour of these creature
This can affect their patterns, their being
Also might enhance or lower their feelings
But a the firefly glows
It can be the spark
An addition to your arc
Where it brightens  the ceiling
```

## Video

<iframe width="560" height="315" src="https://www.youtube.com/embed/bIkeQl4h2So?si=dAuoit5MfByk5hRF"></iframe>

## Code

### Hydra - Scene Effect

```javascript
const d = new Date();
let time = d.getTime();

s0.initScreen()

firefly1 = () => voronoi([10,12,14,100,50,30,75,500,3.5,3,19,100,250,35].smooth(),[14,4,3,9].fast(),3).color([0.5,0.75,1],[0,0.5,0.75,0.86,1].smooth(),[0.1,0.2,0.3,0.4,0.3,0.2,0.1]).scale([0.5,1,2,4,2,1,0.5].smooth())

firefly2 = () => voronoi([10,12,14,100,50,30,75,500,3.5,3,19,100,250,35].smooth(),[14,4,3,9].fast(),3).scroll(2,2).color([0.11,0.36,0.25],[0,0.5,0.75,0.86,1].smooth(),[0.1,0.4,0.3,0.2,0.1]).scale(3)

if(time % 6 > 3)
{

firefly1()
.diff(firefly2().invert()).repeat(2,2)
 .out()
}
else
{
firefly1()
.blend(firefly2())  
  .modulateScale(osc(1,1,1)).scrollX(0.1, 0.01)
  .modulateHue(s0)
 .out()
}


speed = 0.25
```

### Hydra with 360

```javascript
//Part 1

s0.initScreen()

src(s0).repeat([1,2,3].smooth(),2.5).pixelate([15,50000,30,100,10000,500,1000,10000].smooth(),[15,30,45,100,1000,10000].smooth()).diff(s0).out()

speed = 0.45

//Part 2
s0.initScreen()

src(s0).repeat([1,2,3].smooth(),2.5).pixelate([15,50000,30,100,10000,500,1000,10000].smooth(),[15,30,45,100,1000,10000].smooth()).blend(src(s0).scale(1.05)).blend(src(s0).scale(1.35)).blend(src(s0).scale(0.78)).out()

speed = 0.45
```

### Locomotion - Forest Scene

```haskell
directional {z = 2, intensity = range 5 15 (osc 0.5), color = 0x00FfA5};


dancer { url = "Garden.glb", size = range 0.35 4 (osc 0.075), x = range -6 6 (osc 0.1450)};
dancer { url = "Garden.glb", size = range 2 4 (osc 0.075), y = range -6 6 (osc 0.1450)};
dancer { url = "Garden.glb", size = range 1 6 (osc 0.075), z = 13, lz = range 0 90 (osc 0.07)};
```

### Sonic Pi with Effects

```ruby
firefly1 = "E:/Creatuve Code Challenges/FIreflies/Sound/FireflySounds.wav"
firefly2 = "E:/Creatuve Code Challenges/FIreflies/Sound/FireflySounds2.wav"
firefly3 = "E:/Creatuve Code Challenges/FIreflies/Sound/FireflySounds3.wav"


def Sine_ing(looping,samp1,samp2,samp3)
  use_random_seed Time.now.to_i #making true random as it goes with the actual time
  rangeFul = (-27..27).to_a.shuffle() #shuffling a range of numbers from 0 to 27 into an array
  #setting counters
  i = 0
  j = rangeFul.length()
  
  
  
  #setting the live loop
  live_loop looping do
    use_random_seed Time.now.to_i / 3 #making true random as it goes with the actual time
    
    with_fx :echo, mix: Math.sin(j).abs do
      with_fx :distortion,mix: Math.sin(i).abs do
        #If the sin makes the number a negative
        if Math.sin(rangeFul[i]) > 0
          sample [samp1,samp3].choose,rate: Math.sin(rangeFul[i]), decay: Math.cbrt(i) * 3
        end
      end
    end
    
    
    with_fx :ping_pong, mix: Math.sin(i).abs do
      #If the sin makes the number a positive
      if Math.sin(rangeFul[i]) >  0
        sample [samp2,samp3].choose, beat_stretch: Math.cbrt(rangeFul[i].abs)
      end
    end
    
    with_fx :ixi_techno, mix: Math.sin(j).abs do
      with_fx [:vowel,:pitch].tick mix: Math.cos(j).abs do
        #If the sin makes the number 0
        if Math.sin(rangeFul[i]) == 0
          sample [samp1,samp2].choose, decay: dice(12) + 4, rate: rrand(-2,2.4) - 0.1
        end
      end
    end
    
    
    i += 1
    
    if i >= rangeFul.length()
      i = 0
    end
    
    j -= 1
    
    if j <= 0
      j = 0
    end
    
    sleep [Math.sin(i).abs + 0.25,Math.sin(j).abs + 0.25].choose #to avoid the issue with zero
    
  end
end


Sine_ing(:SineFul,firefly3,firefly1,firefly2)
Sine_ing(:SineFul2,firefly2,firefly3,firefly1)
Sine_ing(:SineFul3,firefly1,firefly2,firefly3)
Sine_ing(:SineFul4,firefly1,firefly3,firefly2)
Sine_ing(:SineFul5,firefly3,firefly2,firefly1)
```

## Link to Research/Assets

* [**https://www.youtube.com/watch?v=KipqkzRjQYA**](https://www.youtube.com/watch?v=KipqkzRjQYA)**\- Firefly Sounds**
    
* [**https://www.youtube.com/watch?v=UnM2kGpJrUI**](https://www.youtube.com/watch?v=UnM2kGpJrUI)**\- More Firefly sounds**
    
* [**https://www.youtube.com/watch?v=dRcOVB\_lOlA**](https://www.youtube.com/watch?v=dRcOVB_lOlA)**\- Even more Firefly sounds**
    
* [**https://www.nature.com/articles/s41598-021-91839-3#:~:text=(e)%20Photographs%20of%20the%20firefly,to%20red%20at%2045%20%C2%BAC**](https://www.nature.com/articles/s41598-021-91839-3#:~:text=(e)%20Photographs%20of%20the%20firefly,to%20red%20at%2045%20%C2%BAC)**. - Firefly Range**
    
* [**https://phys.org/news/2010-01-scientists-fireflies-emit.html**](https://phys.org/news/2010-01-scientists-fireflies-emit.html)**\- Firefly information**
    
* [**https://henderson.ces.ncsu.edu/2021/05/blue-ghost-fireflies-do-you-have-them-in-your-woods/#:~:text=The%20bluish%20color%20of%20the,forest%20floor%20and%20glow%20faintly**](https://henderson.ces.ncsu.edu/2021/05/blue-ghost-fireflies-do-you-have-them-in-your-woods/#:~:text=The%20bluish%20color%20of%20the,forest%20floor%20and%20glow%20faintly)**. - Blue Fireflies**
