mixin splat(hue, hoverR, activeR, hoverS, activeS)
.splatted(style=`--hue: ${hue}; --hover-rotate: ${hoverR}; --active-rotate: ${activeR}; --hover-scale: ${hoverS}; --active-scale: ${activeS};`)
.splatted__image
img(src="https://assets.codepen.io/605876/me--standing.png")
img(src="https://assets.codepen.io/605876/me--noticing.png")
img(src="https://assets.codepen.io/605876/me--falling.png")
+splat(110, -10, -30, 1.15, 0.75)
+splat(10, -5, 10, 1.2, 0.85)
+splat(210, 10, 25, 1.1, 0.8)
h1 Tap
View Compiled
*
box-sizing border-box
user-select none
:root
--standing url("https://assets.codepen.io/605876/me--standing.png")
--noticing url("https://assets.codepen.io/605876/me--noticing.png")
--falling url("https://assets.codepen.io/605876/me--falling.png")
// --foundation path("M161 188.375C170 193.5 177.919 193.854 186 188.375C197.919 180.294 197.919 159.581 186 151.5C177.919 146.021 169.081 146.021 161 151.5C149.081 159.581 152 183.25 161 188.375ZM141.5 59.5C131.26 59.5 115.319 40.4876 100.5 52C88.6254 61.2251 85.3244 78.6756 78.5 85.5C72.0365 91.9635 53.1917 106.827 49.5 115C45.1582 124.612 58.5 143.25 58.5 154C58.5 164.751 42.1582 175.888 46.5 185.5C50.1917 193.673 75.1864 202.537 81.6499 209C88.4597 215.81 91.817 237.777 100.5 241.5C109.751 245.467 131.239 237 141.5 237C151.761 237 171.249 254.967 180.5 251C189.183 247.277 204.19 229.31 211 222.5C217.463 216.037 251.308 214.173 255 206C259.342 196.388 249 164.751 249 154C249 142.986 273.5 120 258.5 94C245.5 77 227.5 79 211 75.5C197.5 69 182.331 52.2882 173.5 48.5C164.428 44.6084 151.991 59.5 141.5 59.5ZM138 129C129.877 116.815 108.623 116.815 100.5 129C95.0844 137.123 95.0844 145.877 100.5 154C108.623 166.185 129.877 166.185 138 154C143.416 145.877 143.416 137.123 138 129Z")
--foundation path("M161 188.375C170 193.5 177.919 193.854 186 188.375C197.919 180.294 197.919 159.581 186 151.5C177.919 146.021 169.081 146.021 161 151.5C149.081 159.581 152 183.25 161 188.375ZM141.5 59.5C131.26 59.5 117.936 45.0628 100.5 52C81.6499 59.5 86.0351 73.5325 78.5 85.5C70 99 57.9171 96.3659 49.5 115C40.4659 135 58.5 138 58.5 154C58.5 170 41 166.5 46.5 185.5C52 204.5 72.5 196 81.6499 209C94.5 218.5 81.6499 233.418 100.5 241.5C122.657 251 121.5 232 141.5 237C154.5 237 154.5 257 180.5 251C203.99 245.579 193.5 230 211 222.5C226.5 212.5 236.5 226 255 206C272.51 187.07 247.5 177 249 154C253 132.5 273.5 120 258.5 94C245.5 77 235 78.5 211 75.5C190.5 68 200 53 177.5 49.5C153.5 43.5 161 59.5 141.5 59.5ZM138 129C129.877 116.815 108.623 116.815 100.5 129C95.0844 137.123 95.0844 145.877 100.5 154C108.623 166.185 129.877 166.185 138 154C143.416 145.877 143.416 137.123 138 129Z")
// --warmer path("M161 188.375C170 193.5 177.919 193.854 186 188.375C197.919 180.294 197.919 159.581 186 151.5C177.919 146.021 169.081 146.021 161 151.5C149.081 159.581 152 183.25 161 188.375ZM145.5 70.5C135.26 70.5 104.319 30.4876 89.5 42C77.6254 51.2251 94.3244 85.6756 87.5 92.5C81.0365 98.9635 62.1917 105.827 58.5 114C54.1582 123.612 74.5 143.25 74.5 154C74.5 164.751 35.1582 175.888 39.5 185.5C43.1917 193.673 86.5365 194.537 93 201C99.8099 207.81 71.317 259.777 80 263.5C89.2511 267.467 130.739 222.5 141 222.5C151.261 222.5 173.249 271.967 182.5 268C191.183 264.277 198.69 220.31 205.5 213.5C211.963 207.037 275.808 221.673 279.5 213.5C283.842 203.888 235.5 164.751 235.5 154C235.5 142.986 282.5 113.5 267.5 87.5C254.5 70.5 218 96 201.5 92.5C188 86 184.331 41.7882 175.5 38C166.428 34.1083 155.991 70.5 145.5 70.5ZM138 129C129.877 116.815 108.623 116.815 100.5 129C95.0844 137.123 95.0844 145.877 100.5 154C108.623 166.185 129.877 166.185 138 154C143.416 145.877 143.416 137.123 138 129Z")
--warmer path("M161 188.375C170 193.5 177.919 193.854 186 188.375C197.919 180.294 197.919 159.581 186 151.5C177.919 146.021 169.081 146.021 161 151.5C149.081 159.581 152 183.25 161 188.375ZM145.5 70.5C127 70.5 112 24.5202 89.5 42C77.6254 51.2251 94.3244 85.6756 87.5 92.5C81.0365 98.9635 61.5 85.5 53.5 112C45.5 138.5 74.5 143.25 74.5 154C74.5 164.751 36.6441 162.082 39.5 185.5C42 206 86.5365 194.537 93 201C100.5 213.5 52 251.495 80 263.5C103 273.362 118 222.5 141 222.5C151.261 222.5 156.5 271.5 182.5 268C202.988 265.242 192.5 222.5 205.5 213.5C218.5 204.5 267.5 235 279.5 213.5C292.936 189.427 235.5 171 235.5 154C232.5 135.5 282.5 113.5 267.5 87.5C254.5 70.5 218 96 201.5 92.5C186 84 196 42 175.5 38C157.5 31.5 155.991 70.5 145.5 70.5ZM138 129C129.877 116.815 108.623 116.815 100.5 129C95.0844 137.123 95.0844 145.877 100.5 154C108.623 166.185 129.877 166.185 138 154C143.416 145.877 143.416 137.123 138 129Z")
--splatted path("M232.5 256C225 251 209.5 262.5 224 281.5C232.736 292.948 238.561 297.756 251 290.5C257 287 256.114 271.924 250 264.5C243.886 257.076 240 261 232.5 256ZM147 92.5C107.974 87.5 118 17 93 44C68 71 123.543 76.5 108 101.5C90.5 115 85 99 64 115C64 141 90.5 127 90.5 156C69.5 181.5 27 163.625 24.5 190C49 212.625 58.5 171.5 100 193C105.5 259.345 1 248.5 58.5 291.5C94.5576 318.465 114.991 206.551 140.5 211C183.5 218.5 134.5 294 186.5 279.5C207.5 273 176.5 240.5 196 204C250 196.5 275.916 253 291.5 218.5C311.375 174.5 221 190 224 160C208 123.5 291.5 123.5 267.5 87.5C238.5 57 247 125.5 196 105.5C147 92.5 229.5 13.5 173.5 2.5C140.5 2.49999 186.5 73.5 147 92.5ZM45 92.5C36.8766 80.3149 14.1234 75.3149 6.00001 87.5C0.584412 95.6234 2.00001 120.357 14.5 115C27.9606 109.231 36.8766 124.685 45 112.5C50.4156 104.377 50.4156 100.623 45 92.5Z")
body
display flex
align-items center
justify-content center
flex-wrap wrap
min-height 100vh
background hsl(215, 90%, 95%)
overflow hidden
h1
font-family sans-serif
position fixed
bottom 1rem
right 1rem
margin 0
font-size 3rem
color hsl(215, 90%, 75%)
.splatted
--stance var(--standing)
--splodge var(--foundation)
height 300px
width 300px
position relative
flex 0 0 300px
&:nth-of-type(1)
--img url('https://assets.codepen.io/605876/apple-icon-bg.svg')
&:nth-of-type(2)
--img url('https://assets.codepen.io/605876/code-icon-bg.svg')
&:nth-of-type(3)
--img url('https://assets.codepen.io/605876/dumbbell-icon-bg.svg')
&__image
height 100%
width 100%
clip-path var(--splodge)
transition clip-path 0.2s, transform 0.2s
transform rotate(calc(var(--rotate, 0) * 1deg)) scale(var(--scale, 1))
position relative
background-image var(--img)
background-position calc(var(--x, 0) * 1px) calc(var(--y, 0) * 1px)
background-color 'hsl(%s, 80%, 65%)' % var(--hue)
img
opacity 0
position absolute
height 100%
width 100%
top 50%
left 50%
transform translate(-50%, -50%)
&:nth-of-type(1)
opacity 1
&:nth-of-type(3)
transform translate(-50%, -50%) scale(1.2) translate(0, -5%)
&:hover
--splodge var(--warmer)
--scale var(--hover-scale, 1.1)
--rotate var(--hover-rotate, -15)
img:nth-of-type(1)
img:nth-of-type(3)
opacity 0
img:nth-of-type(2)
opacity 1
&:active
--scale var(--active-scale, 0.8)
--rotate var(--active-rotate, 10)
--splodge var(--splatted)
img:nth-of-type(1)
img:nth-of-type(2)
opacity 0
img:nth-of-type(3)
opacity 1
View Compiled
import gsap from 'https://cdn.skypack.dev/gsap'
const AUDIO = {
IN: new Audio('https://assets.codepen.io/605876/squeak-in.mp3'),
OUT: new Audio('https://assets.codepen.io/605876/squeak-out.mp3'),
}
const bindSound = splat => {
splat.addEventListener('pointerdown', () => {
AUDIO.OUT.pause()
AUDIO.IN.currentTime = AUDIO.OUT.currentTime = 0
AUDIO.IN.play()
})
splat.addEventListener('pointerup', () => {
AUDIO.IN.pause()
AUDIO.IN.currentTime = AUDIO.OUT.currentTime = 0
AUDIO.OUT.play()
})
}
const SPLATS = document.querySelectorAll('.splatted')
SPLATS.forEach(splat => bindSound(splat))
const LIMIT = 25
document.addEventListener('pointermove', ({x, y}) => {
const posX = gsap.utils.mapRange(0, window.innerWidth, LIMIT, -LIMIT, x)
const posY = gsap.utils.mapRange(0, window.innerHeight, LIMIT, -LIMIT, y)
gsap.set(document.documentElement, {
'--x': posX,
'--y': posY,
})
})
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.