cat bounce
buttons, resize, audio
by Nick Hulea
HTML
<script src="https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/pathseg.js"></script>
<script src="https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/decomp.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/matter-js/0.12.0/matter.min.js"></script>
<button id="makeItRainbow" class="btn">
<span class="txt anim-text-flow-hover">Make It Rainbow</span>
</button>
<button id="makeItRain" class="btn">
<span class="txt anim-text-flow-hover">Make It Rain</span>
</button>
<audio id="audio2">
<source src="https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/sound_2.ogg" type="audio/ogg">
<source src="http://aa8f47fcc01b7584f779-b57f388ffba74a9d5600392ce75da4b1.r13.cf2.rackcdn.com/cats/sound_2.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<audio id="audio1">
<source src="https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/sound_1.ogg" type="audio/ogg">
<source src="http://aa8f47fcc01b7584f779-b57f388ffba74a9d5600392ce75da4b1.r13.cf2.rackcdn.com/cats/sound_1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
SCSS
body {
overflow: hidden;
margin: 0px;
width: 100vw;
height: 100vh;
background: -webkit-gradient(linear, left top, left bottom, from(#ef31f9), to(rgba(125, 185, 232, 0)));
background: linear-gradient(180deg, #ef31f9, rgba(125, 185, 232, 0));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ef31f9", endColorstr="#007db9e8", GradientType=0)
}
body,
html {
height: 100vh;
width: 100vw;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
margin: 0;
overflow: hidden
}
.btn {
position: fixed;
top: 0;
margin: 1rem;
-webkit-appearance: none;
border: none;
outline: none;
padding: 10px 20px;
cursor: pointer;
background: none;
color: #fff;
font-weight: 900;
text-transform: uppercase;
font-size: 0.5rem;
}
#makeItRain {
right: 0;
}
#makeItRainbow {
left: 0;
}
/* SMARTPHONES LANDSCAPE */
@media only screen and (min-width: 414px) {
.btn {
font-size: 1.5rem;
}
}
/*
* Animation module with all animation code
*/
.anim-text-flow,
.anim-text-flow-hover:hover {
/*
* Animation variables
*/
$animationSteps: 250;
$animationDuration: 10;
$animationElement: span;
$animationElementsCount: 100;
$delayBetweenLetters: 0.1;
/*
* Elements settings
*/
#{$animationElement} {
animation-name: anim-text-flow-keys;
animation-duration: #{$animationDuration}s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-fill-mode: forwards;
}
/*
* Keyframe loop
*/
@keyframes anim-text-flow-keys {
@for $i from 0 through $animationSteps {
#{percentage($i * (1 / $animationSteps))} {
color: hsla(random(365), 60, 60, 1);
}
}
}
/*
* Element animation delay loop
*/
$totalDelayTime: $animationElementsCount * $delayBetweenLetters;
@for $i from 1 through $animationElementsCount {
#{$animationElement}:nth-of-type(#{$i}) {
animation-delay: #{($i * $delayBetweenLetters) -...
Babel + JSX
console.log(Matter);
const cats = [
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/cat_1.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/cat_2.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/cat_3.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/cat_4.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/cat_5.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/cat_6.png"
];
const rainbow_cats = [
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/rainbow/cat_1.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/rainbow/cat_2.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/rainbow/cat_3.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/rainbow/cat_4.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/rainbow/cat_5.png",
"https://3681a2d2784956323369-b57f388ffba74a9d5600392ce75da4b1.ssl.cf2.rackcdn.com/cats/rainbow/cat_6.png"
];
const Engine = Matter.Engine;
const Render = Matter.Render;
const World = Matter.World;
const Bodies = Matter.Bodies;
const Events = Matter.Events;
const Body = Matter.Body;
const Svg = Matter.Svg;
const Vertices = Matter.Vertices;
const Composites = Matter.Composites;
const MouseConstraint = Matter.MouseConstraint;
const Mouse = Matter.Mouse;
let engine = Engine.create();
const _restitution = 1.0001;
const _friction = 1;
const _frictionAir = 0.0001;
const _frictionStatic = 15;
const _density = 0.01;
const mirainbow = $("#makeItRainbow");
const mirain = $("#makeItRain");
const defaultCategory = 0x0001;
const redCategory = 0x0002;
const greenCategory =...