Code Hoa
Code Hoa
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
integrity="sha512-
JQksK36WdRekVrvdxNyV3B0Q1huqbTkIQNbz1dlcFVgNynEMRl0F8OSqOGdVppLUDIvsOejhr/W5L3G/
b3J+8w=="
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
<style>
.container {
display: flex;
justify-content: center;
align-items: center;
height: 97vh;
.container svg {
width: 50%;
height: 50%;
}
</style>
<style>
*{
margin: 0;
padding: 0;
.hover-animation {
#castle {
position: relative;
width: 100vw;
height: 100vh;
overflow: hidden;
#castle #table {
position: absolute;
width: 400px;
height: 400px;
transform: scaleY(0.225);
#castle .shade-wrap {
position: absolute;
width: 200px;
height: 400px;
position: absolute;
left: 20px;
top: 100px;
width: 160px;
height: 300px;
border-bottom: none;
left: 55px;
top: -14px;
width: 50px;
height: 30px;
border-radius: 100%;
transform: scaleY(0.9);
position: absolute;
left: 70px;
top: -33px;
width: 20px;
height: 20px;
border-radius: 100%;
border-bottom: none;
position: absolute;
bottom: -20px;
width: 100%;
height: 40px;
transform: scaleY(0.5);
border-radius: 100%;
position: relative;
left: 20px;
top: 100px;
width: 160px;
height: 300px;
border-bottom: none;
background-color: #6d6179;
opacity: 0.15;
content: "";
position: absolute;
width: 100%;
height: 100%;
filter: blur(5px);
position: absolute;
width: 100%;
height: 100%;
filter: blur(5px);
position: relative;
top: -50px;
position: absolute;
left: 82px;
top: 187px;
width: 100px;
height: 150px;
background-color: transparent;
left: 97px;
top: 188px;
width: 25px;
height: 25px;
background-color: #c82b60;
content: "";
position: absolute;
height: 100%;
width: 100%;
background-color: transparent;
opacity: 0.9;
position: absolute;
height: 100%;
width: 100%;
background-color: transparent;
position: absolute;
left: 85px;
top: 185px;
width: 25px;
height: 30px;
background-color: #d05478;
opacity: 0.9;
}
#castle .shade-wrap #flower-wrap #petal3 {
position: absolute;
left: 105px;
top: 197px;
width: 25px;
height: 28px;
background-color: #cb5275;
opacity: 0.9;
position: absolute;
left: 80px;
top: 191px;
width: 25px;
height: 25px;
background-color: #d26484;
position: absolute;
left: 105px;
top: 207px;
width: 25px;
height: 20px;
background-color: #d26484;
opacity: 0.9;
position: absolute;
left: 105px;
top: 209px;
width: 22px;
height: 18px;
opacity: 0.9;
position: absolute;
left: 75px;
top: 225px;
width: 13px;
height: 20px;
background-color: #a1b965;
transform: rotate(5deg);
position: absolute;
left: 82px;
top: 265px;
width: 12px;
height: 16px;
background-color: #a1b965;
transform: rotate(-97deg);
.dustDef {
position: absolute;
background-color: white;
border-radius: 100%;
opacity: 0;
@keyframes hover {
0% {
margin-top: 60px;
50% {
margin-top: 50px;
100% {
margin-top: 60px;
@keyframes glow {
0% {
50% {
100% {
@keyframes fall {
5% {
top: 209px;
left: 105px;
opacity: 0.9;
30% {
left: 90px;
55% {
left: 130px;
}
60%,
100% {
top: 380px;
opacity: 0;
@keyframes floatAnimate {
0% {
background-position: 0 0;
opacity: 0.7;
50% {
background-position: 0 0;
opacity: 0.5;
100% {
background-position: 0 0;
opacity: 0.7;
</style>
<style>
svg {
width: 80%;
display: block;
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
text {
fill: #e6668a;
font-family: consolas;
font-size: 9px;
p{
position: absolute;
z-index: 2
label {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
opacity: .8
}
</style>
</head>
<body>
xml:space="preserve">
<defs>
</filter>
" />
</defs>
<text dy="-2">
</textPath>
</text>
style="display:none;" />
</svg>
<script>
let d = shape.getAttribute("d");
let pos = 0; // the position, used to find the indexOf the nth C
class subPath {
constructor(d) {
this.d = d;
this.get_PointsRy();
this.previous = subpaths.length > 0 ? subpaths[subpaths.length - 1] : null;
this.measurePath();
this.get_M_Point(); //lastPoint
this.lastCubicBezier;
this.get_lastCubicBezier();
get_PointsRy() {
this.pointsRy = [];
temp.map(item => {
this.pointsRy.push(parseFloat(item));
measurePath() {
this.pathLength = path.getTotalLength();
get_M_Point() {
if (this.previous) {
let p = this.previous.pointsRy;
let l = p.length;
} else {
let p = this.pointsRy;
get_lastCubicBezier() {
.substring(lastIndexOfC + 1)
.split(/[\s,]/)
temp.map(item => {
_temp.push(parseFloat(item));
});
this.lastCubicBezier = [this.M_point];
this.lastCubicBezier.push(_temp.slice(i, i + 2));
if (i > 0) {
// if it's not the first C
subpaths.push(sPath);
pos = newpos;
subpaths.push(new subPath(d));
let index;
break;
let T;
lengthAtT = pathlength * t;
if (index > 0) {
T=
(lengthAtT - subpaths[index].previous.pathLength) /
(subpaths[index].pathLength - subpaths[index].previous.pathLength);
} else {
T = lengthAtT / subpaths[index].pathLength;
//console.log(T)
return T;
helperPoints.push(p);
// helper point 5 is where the first Bézier ends and where the second Bézier begins
let firstBezier = [
points[0],
helperPoints[0],
helperPoints[3],
helperPoints[5]
];
//console.log(firstBezier)
return firstBezier;
function lerp(A, B, t) {
// 0 <= t <= 1
let ry = [
];
return ry;
let d;
if (index > 0) {
d = subpaths[index].previous.d;
} else {
d = `M${points[0][0]},${points[0][1]} C`;
}
// points.length == 4
d += ` ${points[i][0]},${points[i][1]} `;
//console.log(d)
/*
_t.addEventListener("input", ()=>{
t = _t.value;
lengthAtT = pathlength*t;
T = get_T(t, index);
newPoints = getBezierPoints(T,subpaths[index].lastCubicBezier);
})*/
t = 0.025;
Typing();
theSvg.addEventListener("click", () => {
if (rid) {
window.cancelAnimationFrame(rid);
rid = null;
} else {
if (t >= 1) {
t = 0.025;
rid = window.requestAnimationFrame(Typing);
});
cb.addEventListener("input", () => {
if (cb.checked) {
useThePath.style.display = "block";
} else {
useThePath.style.display = "none";
});
</script>
<div id="table"></div>
<div id="flower-wrap">
<div id="stem"></div>
<div id="petal1"></div>
<div id="petal2"></div>
<div id="petal3"></div>
<div id="petal4"></div>
<div id="petal5"></div>
<div id="falling-petal"></div>
<div id="leaf1"></div>
<div id="leaf2"></div>
</div>
</div>
<div id="shade-main-reflections"></div>
<div id="shade-main">
<div id="shade-handle-big"></div>
<div id="shade-handle-small"></div>
<div id="top-reflection"></div>
<div id="bottom-shade"></div>
</div>
</div>
</div>
c-32.608,29.866-18.892,84.017,24.01,94.752c2.251,0.563,4.612-0.548,5.624-
2.636c0.407-0.841,0.781-1.732,1.138-2.648
C111.438,394.378,103.302,355.204,124.302,328.222z" />
<path class="stickLine"
d="M337.625,212.314c2.37-3.44,1.501-8.149-1.939-10.519c-3.44-2.369-8.15-1.501-
10.519,1.939
c-19.493,28.304-43.492,60.076-72.147,92.853l-2.542-30.875c-0.343-4.163-4-7.261-
8.158-6.917c-4.163,0.343-7.26,3.995-6.917,8.158
l3.721,45.196C172.176,385.546,93.558,449.444,4.053,496.37c-3.699,1.94-
5.127,6.512-3.187,10.211
c1.352,2.579,3.983,4.054,6.705,4.054c1.183,0,2.385-0.279,3.505-0.867c63.84-
33.47,124.784-76.962,181.511-129.479
c5.891-2.031,32.15-10.225,68.671-8.819c4.156,0.167,7.689-3.09,7.85-7.266c0.161-
4.174-3.092-7.689-7.267-7.849
c-18.678-0.721-34.824,0.89-
47.384,3.036C259.688,314.785,301.126,265.31,337.625,212.314z" />
c-13.04-12.394-37.78-21.675-66.625-23.428s-54.527,4.464-68.972,15.187c-
2.653,1.969-3.581,5.568-2.196,8.568
C274.438,393.475,299.525,411.888,329.58,413.715z" />
c-6.645,0.902-13.554,0.516-20.475-1.491c-9.578-2.778-17.805-7.959-24.234-14.68c-
12.216,1.01-22.611,4.593-28.859,9.642
c-1.416,1.145-1.839,3.149-
0.999,4.772c7.157,13.821,21.478,23.41,38.131,23.745c11.548,0.232,22.109-4.035,30.031-11.178
c-2.461,10.379-
1.13,21.692,4.621,31.709c8.293,14.445,23.583,22.401,39.142,22.039c1.826-0.042,3.382-1.376,3.705-
3.168
C377.509,253.982,375.658,243.144,370.677,231.945z" />
l-
1.148,0.092l0.471,1.051c7.005,15.648,9.002,31.447,7.106,48.307l0.877,0.04c11.782,0.538,23.679,3.51
3,35.362,8.841l0.367,0.168
l0.355-0.188c10.841-5.728,22.445-6.783,35.477-
3.225C506.927,108.058,510.397,103.599,508.212,99.848z M452.476,54.541c-4.96-1.457-10.233-2.474-
15.823-2.899c-4.268-0.223-8.58-0.164-12.816,0.176
l-
1.148,0.092l0.471,1.051c7.005,15.648,9.002,31.447,7.106,48.307l0.877,0.04c9.334,0.426,18.74,2.407,2
8.055,5.851
C461.04,88.852,458.784,71.19,452.476,54.541z" />
c4.198,10.201,6.37,19.468,7.545,29.411l0.996-0.402c8.962-3.617,18.525-
6.008,28.405-7.105c3.688-0.322,7.481-0.397,11.274-0.223
c-1.161-9.857-3.49-19.395-7.611-29.408c-20.694-47.084-74.317-58.577-80.363-
59.731c-4.853-0.927-8.31,4.471-5.489,8.546
c21.533,31.149,7.895,59.383-14.633,90.009l0.071,0.029c-16.953,26.497-
7.863,61.237,18.513,76.865
c3.932,2.33,8.219,4.207,12.806,5.537c6.757,1.959,13.752,2.469,20.787,1.514l1.017-
0.138l-0.367-0.959
C330.327,183.817,333.08,162.625,343.8,146.676z" />
<path class="rose4"
d="M510.726,141.7c-3.917-4.747-39.75-46.26-91.009-41.792c-21.664,2.405-52.653,12.308-
77.277,45.856
c-13.392,19.922-
16.495,52.272,4.132,72.986c3.371,3.385,7.075,6.243,11.008,8.573c26.325,15.597,61.186,6.961,76.309-
20.683
l0.077,0.062c15.307-34.399,34.961-59.933,71.9-
56.082C510.802,151.136,513.867,145.507,510.726,141.7z M370.903,162.627c27.904-38.017,75.307-
57.751,121.144-38.743
c-16.072-12.613-41.381-26.674-72.329-23.977c-21.664,2.405-52.653,12.308-
77.277,45.856c-13.392,19.922-16.495,52.272,4.132,72.986
c3.371,3.385,7.075,6.243,11.008,8.573c4.885,2.894,10.125,4.964,15.515,6.228C354.624,212.802,357.9
47,181.899,370.903,162.627z" />
</svg>
color: indianred;
font-size: 50px;
top: 80%;">Click me now !</p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>
<script>
(() => {
setTimeout(() => {
document.querySelector("#text-click").style.display="inherit";
}, 4000);
document.querySelector("#rose-t").onclick = function () {
document.querySelector("#rose-t").style.display = "none";
document.querySelector("#castle").style.display = "inherit";
document.querySelector("#theSvg").style.display = "inherit"
rid = window.requestAnimationFrame(Typing);
function Typing() {
rid = window.requestAnimationFrame(Typing);
if (t >= 1) {
window.cancelAnimationFrame(rid);
rid = null;
} else {
t += 0.0025;
}
lengthAtT = pathlength * t;
break;
T = get_T(t, index);
let animationId = 1;
function CreateMagicDust(x1, x2, y1, y2, sizeRatio, fallingTime, animationDelay, node = 'main') {
animation.innerHTML = '\
0% {\
opacity: .4\
}\
20% {\
}\
35% {\
opacity: .5\
}\
55% {\
opacity: .7\
}\
80% {\
opacity: .3\
}\
100% {\
opacity: .1\
}}';
head.appendChild(animation);
dust.classList.add('dustDef');
document.getElementById(node).appendChild(dust);
}
// yes, I'm doing it manually to get the effect I want.. can be easily changed to render randomly
})();
</script>
<script>
easing: 'easeInOutCubic',
duration: 4000,
//Leaf One
leafOne.setAttribute("stroke", "black");
leafOne.setAttribute("fill", "none");
// Leaf Two
leafTwo.setAttribute("stroke", "black");
leafTwo.setAttribute("fill", "none");
//Stick
stickLine.setAttribute("stroke", "black");
stickLine.setAttribute("fill", "none");
// Leaf S1
leafS1.setAttribute("stroke", "black");
leafS1.setAttribute("fill", "none");
//Rose One
rose1.setAttribute("stroke", "black");
rose1.setAttribute("fill", "none");
//Rose Two
rose2.setAttribute("stroke", "black");
rose2.setAttribute("fill", "none");
//Rose Three
rose3.setAttribute("stroke", "black");
rose3.setAttribute("fill", "none");
//Rose Three
rose4.setAttribute("stroke", "black");
rose4.setAttribute("fill", "none");
},
//Leaf One
leafOne.setAttribute("fill", "#9CDD05");
leafOne.setAttribute("stroke", "none");
//Leaf Two
leafTwo.setAttribute("fill", "#9CDD05");
leafTwo.setAttribute("stroke", "none");
//Stick
stickLine.setAttribute("fill", "#83AA2E");
stickLine.setAttribute("stroke", "none");
// Leaf S1
leafS1.setAttribute("fill", "#9CDD05");
leafS1.setAttribute("stroke", "none");
// Rose 1
rose1.setAttribute("fill", "#F37D79");
rose1.setAttribute("stroke", "none");
// Rose 2
rose2.setAttribute("fill", "#D86666");
rose2.setAttribute("stroke", "none");
// Rose 3
rose3.setAttribute("fill", "#F37D79");
rose3.setAttribute("stroke", "none");
// Rose 3
rose4.setAttribute("fill", "#D86666");
rose4.setAttribute("stroke", "none");
},
autoplay: true,
});
</script>
</body>
</html>