100 Lessons 100 Days: Day 2
Tags: webdev
Published: 2020-08-07 07:00:46

# Soothing Bubbles

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Before I even get into the the what I actually learned about today I have to mention that my ideas for today's project started out as something wildly different. A simply app where you would click on the screen to place a particle emitter that would spray for a few seconds. Somewhere between the beginning and the end my wife caught a glimpse of the project, which was little more than pretty bubbles floating about and she became entranced by the way they danced across the screen. So I chucked my original idea in the bin and made an agile, dynamic paradigm shift(and perhaps several other buzzwords).





## Lesson: Particles.js

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I have made many animations in my career, from silky smooth transitions to the pulsing neon button that I swear sounded like a good idea at the time. However I have never really dipped my toe into more advanced animation on the net that the big names frameworks could provide. Wanting to start out small I turned to Particle.js to tackle first, or more specifically react-particle-js for ease of integration with the Next.js framework I had already built out. 

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I found the basics farely straight forward. Start with the install
<pre><code>npm install react-particle-js || yarn add react-particle-js</code></pre>

Then once imported we can use the Particle component and customize it with the params attribute to customize it. 

```
import Particles from "react-particle-js"
const Bubble=()=>{
   return( 
     <Particles
        params={{
          background: {
            color: {
              value: '#0d47a1',
            },
          },
          particles: {
            number: {
              value: 150,
              density: {
                enable: true,
                value_area: 1200,
              },
            },
            color: {
              value: ['#E58F65', '#baf2e9', '#bad7f2', '#925e78', '#706993'],
            },
            size: {
              value: `${size}`,
              random: true,
              anim: {
                enable: true,
                speed: 5.2,
                size_min: 0.01,
              },
            },
            shape: {
              type: 'circle',
              stroke: {
                width: `${strokeSize}`,
                color: '#3fb7FF',
              },
            },
            links: {
              enable: false,
            },
          },
        }}
      />
```

I was surprised by the minute amount of code to get such an impressive effect. The final product uses some real basic state management to  control the size of the particle and the stroke around it, which offers some pretty cool effects (my favorite is particle size of 2 and stroke size of 500)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; After digging around at some the of the examples of what others have created with Particles, I know it will be a tech I revisit several times in this series. 


That is all for today. You can find [100 Lessons, 100 Days]([https://site-a-day.vercel.app/](https://site-a-day.vercel.app/)) at it's current home hosted by the great people at Vercel.  Never Stop Coding!!!