Winter Scene

Developer
Size
2,739 Kb
Views
4,046

How do I make an winter scene?

Simple animation using some unicode characters.... What is a winter scene? How do you make a winter scene? This script and codes were developed by Jeff Daze on 18 January 2023, Wednesday.

Winter Scene Previews

Winter Scene - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Winter Scene</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="body-wrapper"> <div class="wrapper"> <!-- <div class="snowflake sn1">&#10052;</div> <div class="snowflake">&#10053;</div> <div class="snowflake">&#10054;</div> --> <div class="snowman">&#9731;</div> <button id="run">run</button> <button id="stop">stop</button> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Winter Scene - Script Codes CSS Codes

.snowflake{ font-size:84px; color:#FFF; position:absolute; left: 200px; top:10px;
}
.snowman{ position:absolute; bottom:1px; width:100%; text-align:center; font-size:200px; color:#FFF;
}
.wrapper { min-height: 100%; height: auto !important; height: 100%; background: #1E5799; /* old browsers */ background: -moz-linear-gradient(top, #002c5a 0%, #EAEAEA 100%); /* firefox */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#002c5a), color-stop(100%,#EAEAEA)); /* webkit */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#002c5a', endColorstr='#EAEAEA',GradientType=0 ); /* ie */
}
.body-wrapper { height: 1000px; width: 100%;
}

Winter Scene - Script Codes JS Codes

var degree = 0;
var runner;
$("#run").click(function(){ runner = setInterval(run, 800);
});
$("#stop").click(function(){ clearInterval(runner);
});
function run(){ // $( ".sn1" ).animate({ "top": "+=50px", "left": "+=20px" }).animate({ "top": "+=50px", "left": "-=20px" }); var newElem = $('<div class="snowflake" />').html(randFlake()).appendTo($(document.body)).css({"left": randVal($( window ).width())+"px", "fontSize": randVal(30, 5)+"px"}); var start = null;
function step(timestamp) { var progress; if (start === null) start = timestamp; progress = timestamp - start; randMove(newElem); if (progress < 2500) { requestAnimationFrame(step); }
}
requestAnimationFrame(step);
}
//3 different kinds of flake glyph...
function randFlake(){ var glyphs = ["&#10052;","&#10053;","&#10054;"]; return glyphs[randVal(glyphs.length)];
}
function randMove(element){ var jitter = randVal(4); var coin = randVal(3); //flip a coin! if(coin == 1){ //$(element).animate({"top": "+=100px", "left": "+="+jitter+"px"}); $(element).css({"top": "+=5px", "left": "+="+jitter+"px"}); }else if(coin == 2){ //$(element).animate({"top": "+=100px", "left": "-="+jitter+"px"}); $(element).css({"top": "+=5px", "left": "-="+jitter+"px"}); }else{ $(element).css({"top": "+=5px"}); } //rotate... degree = degree + 1; $(element).css({'-webkit-transform': 'rotate(' + degree + 'deg)', '-moz-transform': 'rotate(' + degree + 'deg)', '-ms-transform': 'rotate(' + degree + 'deg)', '-o-transform': 'rotate(' + degree + 'deg)', 'transform': 'rotate(' + degree + 'deg)'});
}
function randVal(val, offset){	//set a default value of 0 for offset...	offset = typeof offset !== 'undefined' ? offset : 0;	return Math.floor(Math.random() * val)+offset;
}
Winter Scene - Script Codes
Winter Scene - Script Codes
Home Page Home
Developer Jeff Daze
Username jeffdaze
Uploaded January 18, 2023
Rating 3
Size 2,739 Kb
Views 4,046
Do you need developer help for Winter Scene?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Jeff Daze (jeffdaze) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!