Unfinished sunrise

Developer
Size
2,912 Kb
Views
38,456

How do I make an unfinished sunrise?

What is a unfinished sunrise? How do you make a unfinished sunrise? This script and codes were developed by Tcmulder on 05 August 2022, Friday.

Unfinished sunrise Previews

Unfinished sunrise - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Unfinished sunrise</title> <script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <svg id="svg" width="100" height="100" viewBox="0 0 1000 1000" preserveAspectRatio="xMidYMid slice"></svg> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.1.0/snap.svg-min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Unfinished sunrise - Script Codes CSS Codes

html, body { height: 100%; text-align: center;
}
body { background: #000;
}
body:before { content: ""; display: inline-block; vertical-align: middle; height: 100%; margin: -.25em;
}
svg { display: inline-block; width: 100%; height: 100%; max-width: 800px; max-height: 600px; vertical-align: middle;
}

Unfinished sunrise - Script Codes JS Codes

//intitialize snap
var s = Snap('#svg');
//set filters and gradients
var glow = s.filter(Snap.filter.shadow(0,0,10,'#fff'));
var gradNight = s.gradient( 'L(0, 0, 0, 1000)'+ Snap.hsl(195, 95, 1) +'-'+ Snap.hsl(195, 95, 5) +':50-'+ Snap.hsl(195, 95, 15)
);
var gradDusk = s.gradient( 'L(0, 0, 0, 1000)'+ Snap.hsl(200, 95, 10) +'-'+ Snap.hsl(200, 95, 20) +':50-'+ Snap.hsl(20, 85, 30)
);
var gradDay = s.gradient( 'L(0, 0, 0, 1000)'+ Snap.hsl(210, 51, 30) +'-'+ Snap.hsl(210, 45, 45) +':50-'+ Snap.hsl(210, 40, 65)
);
var gradDawn = s.gradient( 'L(0, 0, 0, 1000)'+ Snap.hsl(220, 75, 30) +'-'+ Snap.hsl(210, 40, 55) +':50-'+ Snap.hsl(50, 95, 70)
);
//set objects
var skyFrom = s.rect(0,0,1000,1000);
var skyTo = skyFrom.clone();
var stars = s.g();
for(i=0; i<500; i++){ var randY = Math.floor(Math.random() * 1000) + 1; var randX = Math.floor(Math.random() * 1000) + 1; var randW = Math.random() * 1 + .3; var randO = (Math.floor(Math.random() * 7) + 1) / 10; stars.add( s .circle(randX,randY,randW) .attr({ opacity: randO, fill: '#fff' }) );
}
var sun = s.circle(110,220,80);
//apply attributes
sun.attr({ filter: glow, fill: '#fff', transform: 't0,1000'
});
//animate
var riseSet = function(){ console.clear(); Snap.animate(0, 1, function (val) { //move the sun var x = (val*1200 - 200); var y = 0; if(val < .5){ y = 500 * (1 - val*2) * (1 - val*2); } else { y = 500 * (1 - val*2) * (1 - val*2); } sun.attr({ transform: 't'+x+','+y }); //move the sky var color1 = null; var color2 = null; var color3 = null; var per = 0; //night if(val < .25){ per = val/.25; skyFrom.attr({ fill:gradNight, opacity: 1 }); skyTo.attr({ fill:gradDawn, opacity: per }); stars.attr({ opacity: 1-per }); //dawn } else if(val < .5){ per = (val-.25)/(.5-.25); skyFrom.attr({ fill:gradDawn, opacity: 1 }); skyTo.attr({ fill:gradDay, opacity: per }); //day } else if(val < .75){ per = (val-.5)/(.75-.5); skyFrom.attr({ fill:gradDay, opacity: 1 }); skyTo.attr({ fill:gradDusk, opacity: per }); stars.attr({ opacity: per }); //dusk } else { per = (val-.75)/(1-.75); skyFrom.attr({ fill:gradDusk, opacity: 1 }); skyTo.attr({ fill:gradNight, opacity: per }); } }, 15000, riseSet);
}
riseSet();
Unfinished sunrise - Script Codes
Unfinished sunrise - Script Codes
Home Page Home
Developer Tcmulder
Username tcmulder
Uploaded August 05, 2022
Rating 3
Size 2,912 Kb
Views 38,456
Do you need developer help for Unfinished sunrise?

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!

Tcmulder (tcmulder) Script Codes
Create amazing marketing copy 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!