randhir css project
randhir css project
TECHNICAL EDUCATION
Gargoti
MICRO PROJECT
TITLE OF PROJECT
Certificate
This is to certify that Roll no. of V Semester of Diploma in Computer Engineering of
Institute, VVIT, Pal (Code: 1207) has completed the Micro Project satisfactorily in Subject
INDEX
1
Introduction 4
2 Objective 5
3
Description and Tool used 5
4 Advantages 6
5 Program 7
6 Output 12
7
Conclusion 13
Introduction
Objective
Description of Project
Advantages
1. User will get more attractive towards the virtual images of the solar system.
2. This will increase the user interest on the action perform on graphical
animation.
3. User get more information by seeing virtual images.
Program
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<meta charset="utf-8">
<title>Solar System</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<img class="object" src="sun.png" alt="" id="sun">
<img class="object planet" src="mercury.png" alt="" id="mercury">
<img class="object planet" src="venus.png" alt="" id="venus">
<img class="object planet" src="earth.png" alt="" id="earth">
<img class="object planet" src="mars.png" alt="" id="mars">
<img class="object planet" src="jupiter.png" alt="" id="jupiter">
<img class="object planet" src="saturn.png" alt="" id="saturn">
<img class="object planet" src="uranus.png" alt="" id="uranus">
<img class="object planet" src="neptune.png" alt="" id="neptune">
<div class="object" id="moon"></div>
Main.css
body {
background: black;
margin: 0;
padding: 0;
height: 200vmin;
}
.object {
border-radius: 50%;
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
transform: translateY( 50vmin );
}
.p-orbit, #m-orbit{
border: 0.1vmin solid lightgrey;
opacity: 0.5;
background: transparent;
}
#belt {
height: 97vmin;
width: 97vmin;
animation: spin 50s infinite linear;
margin-top: 50vmin;
V.V.I.T. Pal pg. 8
Developing Animated Solar System using JS
@keyframes spin{
0%{ transform: rotate(0deg) }
100%{ transform: rotate(360deg) }
}
#m-orbit {
height: 8vmin;
width: 8vmin;
}
.planet, #moon {
z-index: 100;
}
#sun {
height: 12vmin;
width: 12vmin;
}
#moon {
height: 1vmin;
width: 1vmin;
background-color: white;
}
#mercury {
height: 2vmin;
width: 2vmin;
}
#venus {
height: 3vmin;
width: 3vmin;
}
#earth {
height: 4vmin;
width: 4vmin;
}
#mars {
height: 3.5vmin;
width: 3.5vmin;
}
#jupiter {
height: 12vmin;
width: 12vmin;
}
#saturn {
height: 12vmin;
width: 12vmin;
border-radius: 0%;
}
#uranus {
height: 5vmin;
width: 5vmin;
}
#neptune {
height: 4vmin;
width: 4vmin;
}
script.js
p_orbits.forEach((p_orbit, index)=>{
p_orbit.style.height = `${p_radii[index]}vmin`
p_orbit.style.width = `${p_radii[index]}vmin`
})
setInterval( ()=> {
planets.forEach( (planet, index)=>{
planet.style.left = `${Math.cos(p_radians[index]) * p_radii[index]}vmin`
planet.style.top = `${Math.sin(p_radians[index]) * p_radii[index]}vmin`
p_radians[index] += p_velocities[index] * 0.02
})
m_orbit.style.left = `${earthX()}vmin`
m_orbit.style.top = `${earthY()}vmin`
}, 1000/60)
function earthX(){
return Number( planets[2].style.left.split('vmin')[0] )
}
function earthY(){
return Number( planets[2].style.top.split('vmin')[0] )
}
Output
Conclusion