Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!--
#    __  __           _        _             __  __              #
#   |  \/  |         | |      | |           |  \/  |             #
#   | \  / | __ _  __| | ___  | |__  _   _  | \  / | __ ___  __  #
#   | |\/| |/ _` |/ _` |/ _ \ | '_ \| | | | | |\/| |/ _` \ \/ /  #
#   | |  | | (_| | (_| |  __/ | |_) | |_| | | |  | | (_| |>  <   #
#   |_|  |_|\__,_|\__,_|\___| |_.__/ \__, | |_|  |_|\__,_/_/\_\  #
#                                     __/ |                      #
#                                    |___/                       #
-->

<body>  
  <div class="container">
    <p><small>Add participants separated by commas and hit START!</small></p>
    <textarea id="textarea" placeholder="Add participants..."></textarea> 
  
    <br/><br/>
  
    <a href="#down"><button onclick="randomSelect();setTimeout(initConfetti, 6000)" class="button">START</button></a>
 
 <!--this autoscrolls down to participants after button press-->
      <div id="down"></div>
   
      <br/><br/><br/>
  
<!--this draws the participant tags-->
  
  <div id="tags"></div>	
  
<!--this draws the confetti-->
  
  <canvas class="confetti" id="canvas"></canvas>
  
</body>  
 
<footer>
  <div class="footer">
  
<!-- add your logo and website link below -->
    
    
  
  <a href="https://www.youtube.com/awesomoto" alt"Follow Awesomoto">
    <img class="a" src="https://www.maxkeeley.com/projects/awesomoto//subscriber_rewards/img/img5.png" width="40px" alt="Image">
    
  <p class="small"> Follow @Awesomoto to win!</p>
  </a>
  </footer>
  </div>
  </div>
</html>
              
            
!

CSS

              
                
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
 }

 a {
  text-decoration: none;
  color: black;
 } 
 
p {
  color: #bcbcbc;
}

body {
  display: flex;
  background: linear-gradient( rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.9) ), url('https://www.maxkeeley.com/projects/awesomoto/subscriber_rewards/img/img3.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-color: #181516;
  font-family: sans-serif;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 10px;
  text-align: center;
}

textarea {
  border: 0;
  display: center;
  font-family: inherit;
  font-size: 16px;
  margin: 0 0 0 0;
  padding: 10px;
  height: 40px;
  width: 50%;
  border-radius: 12px;
  color: #181516
}

 #down {
  margin-top: .1%;
  padding-bottom: .1%;
 } 


.container {
  width: 100%;
  max-width: 100%;
}

.tag {
  background-color: #999999;
  border-radius: 90px;
  color: #000;
  display: inline-block;
  font-size: 14px;
  padding: 12px 24px;
  margin: 0 3px 3px 0;
}

.tag.highlight {
  background-color: #F4C900;
}

.button {
  background-color: #F4C900; /* Green */
  border-radius: 12px;
  border: none;
  display: float;
  color: black;
  padding: 15px 15px;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
}

.footer {
  position: fixed;
  right: 0rem;
  bottom: 0rem;
  left: 0rem;
  padding: 0rem;
  background: rgba(0, 0, 0, .75);

  text-align: center;
  color: #0099ff;
}

.small{
  color: #F4C900;
   font-size: 14px;
}


.a {
    
    animation: pulse 2s linear infinite;
}

@-webkit-keyframes "pulse" {
0% {
    -webkit-transform: scale(1.0);
    transform: scale(1.0);
}
50% {
   -webkit-transform: scale(0.8);
   transform: scale(0.8);
}
100% {
    -webkit-transform: scale(1);
   transform: scale(1);
}
}
              
            
!

JS

              
                 const tagsEl = document.getElementById('tags');
 const textarea = document.getElementById ('textarea');

textarea.addEventListener('keyup', (e) => {

	createTags(e.target.value);


	if(e.click === 'click') {
		e.target.value = '';

		randomSelect();
	}
});


function createTags(input) {
	const tags = input.split(',').filter(tag => tag.trim() !== '').map(tag => tag.trim());

	tagsEl.innerHTML = '';

	tags.forEach(tag => {
		const tagEl = document.createElement('span');
		tagEl.classList.add('tag');
		tagEl.innerText = tag;
		tagsEl.appendChild(tagEl);
	});
}



function randomSelect() {
  const times = 50;
  
  const interval = setInterval(() => {
    const randomTag = pickRandomTag();
    highlightTag(randomTag);
    
    setTimeout(() => {
      unhighlightTag(randomTag);
    }, 100);
  }, 100);


  
  setTimeout(() => {
      clearInterval(interval);
    
      setTimeout(() => {
        const randomTag = pickRandomTag();
        highlightTag(randomTag);
    
    }, times * 20);
  }, times * 100);
}



function pickRandomTag() {
  const tags = document.querySelectorAll('.tag');
  return tags[Math.floor(Math.random() * tags.length)];
}


   
function highlightTag(tag) {
  tag.classList.add('highlight');
}



function unhighlightTag(tag) {
  tag.classList.remove('highlight');
}



//Variables
canvas = document.getElementById("canvas");
ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
cx = ctx.canvas.width / 2;
cy = ctx.canvas.height / 2;

let confetti = [];
const confettiCount = 200;
const gravity = 0.5;
const terminalVelocity = 5;
const drag = 0.050;
const colors = [
{ front: 'red', back: 'darkred' },
{ front: 'green', back: 'darkgreen' },
{ front: 'blue', back: 'darkblue' },
{ front: 'yellow', back: 'darkyellow' },
{ front: 'orange', back: 'darkorange' },
{ front: 'pink', back: 'darkpink' },
{ front: 'purple', back: 'darkpurple' },
{ front: 'turquoise', back: 'darkturquoise' }];



//Functions
resizeCanvas = () => {
  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;
  cx = ctx.canvas.width / 2;
  cy = ctx.canvas.height / 2;
};

randomRange = (min, max) => Math.random() * (max - min) + min;

initConfetti = () => {
  for (let i = 0; i < confettiCount; i++) {
    confetti.push({
      color: colors[Math.floor(randomRange(0, colors.length))],
      dimensions: {
        x: randomRange(10, 20),
        y: randomRange(10, 30) },

      position: {
        x: randomRange(0, canvas.width),
        y: canvas.height - 1 },

      rotation: randomRange(0, 2 * Math.PI),
      scale: {
        x: 1,
        y: 1 },

      velocity: {
        x: randomRange(-25, 25),
        y: randomRange(0, -50) } });

  }
};



//Render
render = () => {
  ctx.clearRect(0, 0, canvas.width, canvas.height);

  confetti.forEach((confetto, index) => {
    let width = confetto.dimensions.x * confetto.scale.x;
    let height = confetto.dimensions.y * confetto.scale.y;

    ctx.translate(confetto.position.x, confetto.position.y);
    ctx.rotate(confetto.rotation);

    confetto.velocity.x -= confetto.velocity.x * drag;
    confetto.velocity.y = Math.min(confetto.velocity.y + gravity, terminalVelocity);
    confetto.velocity.x += Math.random() > 0.5 ? Math.random() : -Math.random();

    confetto.position.x += confetto.velocity.x;
    confetto.position.y += confetto.velocity.y;

    if (confetto.position.y >= canvas.height) confetti.splice(index, 1);

    if (confetto.position.x > canvas.width) confetto.position.x = 0;
    if (confetto.position.x < 0) confetto.position.x = canvas.width;

    confetto.scale.y = Math.cos(confetto.position.y * 0.1);
    ctx.fillStyle = confetto.scale.y > 0 ? confetto.color.front : confetto.color.back;

    ctx.fillRect(-width / 2, -height / 2, width, height);

    ctx.setTransform(1, 0, 0, 1, 0, 0);
  });

  window.requestAnimationFrame(render);
};



//Execution

initConfetti();
render();

window.addEventListener('resize', function () {
  resizeCanvas();
});
              
            
!
999px

Console