Canvas snow
How do I make an canvas snow?
Just a test demo . What is a canvas snow? How do you make a canvas snow? This script and codes were developed by IEkiller on 17 January 2023, Tuesday.
Canvas snow - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>canvas snow</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="iDiv"> <input type="button" value="小雪"/> <input type="button" value="中雪"/> <input type="button" value="大雪"/> </div> <canvas id="can1" width= 1000 height=800 ></canvas> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Canvas snow - Script Codes CSS Codes
body{ background:#333;} #iDiv{width:200px; height:30px; background: #333; position: fixed; right:50px; bottom:30px;}
Canvas snow - Script Codes JS Codes
window.onload = function(){ var oSnow = new SnowCan({num:'500'}); var iDiv = document.getElementById('iDiv'); var aInput = iDiv.getElementsByTagName('input'); aInput[0].onclick = function(){ oSnow.num = 100; oSnow.init(); } aInput[1].onclick = function(){ oSnow.num = 500; oSnow.init(); } aInput[2].onclick = function(){ oSnow.num = 1000; oSnow.init(); } } function SnowCan(oJson){ var oJson = oJson || {}, oC = document.getElementById(oJson.id) || document.getElementsByTagName('canvas')[0]; this.oCG = oC.getContext('2d'); this.oCG.clipContent= false; this.num = oJson.num || 100; this.aColor = oJson.aColor || ['#fff','#eee']; this.GLSpeed = oJson.GLspeed || 0; this.aSnowW = [1,2,3]; this.docW = oJson.docW || oC.width; this.docH = oJson.docH || oC.height; this.timer = null; this.jPo = { x : [], y : [] }; this.jSp = { x : [1,0.5,1.2,-1,-0.5], y : [1.5,2.5,3.8,3.5] }; this.init(); var _this = this; this.timer = setInterval(function(){ _this.oCG.clearRect(0,0,_this.docW, _this.docH); _this.creatArc(); },1000/60); } SnowCan.prototype.init = function(){ this.jPo.x = toRandom(-this.docW, this.docW, this.num); this.jPo.y = toRandom(-this.docH, this.docH, this.num); this.oCG.fillStyle = this.aColor[0]; this.creatArc(); console.log(this.jPo) } SnowCan.prototype.creatArc = function(){ for( var i = 0; i< this.num ; i++){ this.oCG.beginPath(); this.oCG.arc(this.jPo.x[i], this.jPo.y[i], this.aSnowW[i%this.aSnowW.length], 0 ,2*Math.PI); this.oCG.closePath(); this.oCG.fill(); this.jPo.x[i]+= this.jSp.x[i%this.jSp.x.length]/2 ; this.jPo.y[i]+= this.jSp.y[i%this.jSp.y.length]/2; if(this.jPo.x[i] > this.docW + 10 || this.jPo.x[i] < 0 - 10 || this.jPo.y[i] > this.docH + 10){ this.jPo.x[i] = getRandom(0, this.docW); this.jPo.y[i] = getRandom(-100, 0); } } } function toRandom(iMin,iMax,iNum){ var json={}; var arr=[]; while(arr.length<iNum) { var rnum=Math.floor(Math.random()*(iMax-iMin))+iMin; if(!json[rnum]) { json[rnum]=rnum; arr.push(rnum); } } return arr; }
function getRandom(iMin,iMax){ return Math.round(Math.random()*(iMax-iMin))+iMin;
}

Developer | IEkiller |
Username | win7killer |
Uploaded | January 17, 2023 |
Rating | 3 |
Size | 2,572 Kb |
Views | 6,069 |
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!
Name | Size |
Css border amazing-2 | 1,529 Kb |
Canvas_paint | 3,104 Kb |
Timer | 2,291 Kb |
A Pen by IEkiller | 6,561 Kb |
Canvas ball | 2,836 Kb |
Css3-eyes | 1,807 Kb |
Dir tree | 3,169 Kb |
Points-line | 2,396 Kb |
Rote 4 | 2,986 Kb |
Rain Of Text | 2,463 Kb |
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!
Name | Username | Size |
Simple jQuery Slider | Jurbank | 2,874 Kb |
Birthday Party Starter | Aussieyang | 1,629 Kb |
Resizable SASS Icons | Marianarlt | 7,611 Kb |
Display properties | Hamzaerbay | 1,886 Kb |
Scifi-style Radio-based Tab | Aaronchuo | 4,427 Kb |
Expert Help | SinceSidSlid | 4,064 Kb |
Perforated foil | 0x04 | 2,617 Kb |
Material Design-Layout-Principles Practice | Fraina | 2,331 Kb |
A Pen by Eka Risyana | Risyana | 3,705 Kb |
Perspective Origin Demo | Agelber | 3,614 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!