<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CS420 Assignment 2 Solution and Discussion]]></title><description><![CDATA[<p dir="auto">Re: <a href="/topic/729/cs420-assignment-2-solution-and-discussion">CS420 Assignment 2 Solution and Discussion</a></p>
<p dir="auto">Assignment No. 02<br />
Semester: Spring 2020<br />
CS420 – Web Development for Portable Devices</p>
<p dir="auto">Total Marks: 20</p>
<p dir="auto">Due Date: 15/06/2020</p>
<p dir="auto">Lectures Covered: This assignment covers Lectures of week # 1 to 5.</p>
<p dir="auto">Uploading instructions:</p>
<p dir="auto">Please read the following instructions carefully before solving &amp; submitting the assignment:</p>
<ol>
<li>The assignment will not be accepted after due date.</li>
<li>Zero marks will be awarded if the assignment does not open or the file is corrupt.</li>
<li>The assignment file must be a .zip/.rar file format; Assignment will not be accepted in any other format.</li>
<li>Zero marks will be awarded if assignment is copied (from other student or copied from handouts or internet).</li>
<li>Zero marks will be awarded if Student ID is not mentioned in the assignment file.</li>
</ol>
<p dir="auto">For any query about the assignment, contact only at <a href="mailto:CS420@vu.edu.pk" target="_blank" rel="noopener noreferrer nofollow ugc">CS420@vu.edu.pk</a><br />
Please do not post queries related to assignment on MDB.</p>
<p dir="auto">Rules for Marking:</p>
<p dir="auto">It should be clear that your assignment will not get any credit if:</p>
<p dir="auto">•	The assignment is submitted after due date.<br />
•	The submitted assignment does not open, execute or file is corrupted.<br />
•	Your assignment is copied from internet, handouts or from any other student<br />
(Strict disciplinary action will be taken in this case).</p>
<p dir="auto">Assignment</p>
<p dir="auto">Question  (20 Marks)</p>
<p dir="auto">You are required to develop an HTML5 based webpage which draws an Animated Solar System (i.e. moon revolves around earth and earth revolves around the sun) on canvas.<br />
Here is a screenshot of a sample page.<br />
<img src="https://i.imgur.com/XefCviH.png" alt="194bc196-4daa-4876-b644-1cf87cbe767c-image.png" class=" img-fluid img-markdown" /><br />
Your Task is to make such a page suitable for portable devices. You can use concepts of HTML5, CSS and JavaScript etc.</p>
<p dir="auto">NOTE:  Do not put any query on MDB about this assignment, if you have any query then email at <a href="mailto:cs420@vu.edu.pk" target="_blank" rel="noopener noreferrer nofollow ugc">cs420@vu.edu.pk</a>.  Furthermore, if any student found cheating from any other student or from online forums then he/she will be awarded ZERO right away and strict disciplinary action will be taken against the student.</p>
<p dir="auto">You will compress all necessary files. Upload the compressed file on VU-LMS on or before 15/06/2020.</p>
]]></description><link>https://community.secnto.com//topic/1931/cs420-assignment-2-solution-and-discussion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 20:45:46 GMT</lastBuildDate><atom:link href="https://community.secnto.com//topic/1931.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Jun 2020 16:06:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CS420 Assignment 2 Solution and Discussion on Tue, 21 Jul 2020 08:53:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cyberian" aria-label="Profile: cyberian">@<bdi>cyberian</bdi></a> said in <a href="/post/5423">CS420 Assignment 2 Solution and Discussion</a>:</p>
<blockquote>
<p dir="auto">You are required to develop an HTML5 based webpage which draws an Animated Solar System (i.e. moon revolves around earth and earth revolves around the sun) on canvas.<br />
Here is a screenshot of a sample page.</p>
<p dir="auto">Your Task is to make such a page suitable for portable devices. You can use concepts of HTML5, CSS and JavaScript etc.</p>
</blockquote>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="UTF-8"&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
        &lt;title&gt;CS420 - Assignment # 2&lt;/title&gt;
    &lt;/head&gt;

    &lt;body&gt;
        &lt;canvas id="canvas" width="1000" height="1000"&gt;&lt;/canvas&gt;

        &lt;script&gt;

            var sun = new Image();
            var moon = new Image();
            var earth = new Image();
            
            function init() {
                sun.src = 'images/canvas_sun.png';
                moon.src = 'images/canvas_moon.png';
                earth.src = 'images/canvas_earth.png';
                window.requestAnimationFrame(draw);
            }

            function draw() {
                
                var ctx = document.getElementById('canvas').getContext('2d');

                ctx.globalCompositeOperation = 'destination-over';
                ctx.clearRect(0, 0, 800, 800); // clear canvas
                
                ctx.fillStyle = 'rgba(0, 0, 0, 0.4)';
                ctx.strokeStyle = 'rgba(0, 153, 255, 0.4)';
                ctx.save();
                ctx.translate(400, 400);

                // Earth
                var time = new Date();
                ctx.rotate(((2 * Math.PI) / 60) * time.getSeconds() + ((2 * Math.PI) / 60000) * time.getMilliseconds());
                ctx.translate(205, 0);
                ctx.fillRect(0, -12, 40, 24); // Shadow
                ctx.drawImage(earth, -12, -12);

                // Moon
                ctx.save();
                ctx.rotate(((2 * Math.PI) / 6) * time.getSeconds() + ((2 * Math.PI) / 6000) * time.getMilliseconds());
                ctx.translate(0, 28.5);
                ctx.drawImage(moon, -3.5, -3.5);
                ctx.restore();

                ctx.restore();

                ctx.beginPath();
                ctx.arc(400, 400, 205, 0, Math.PI * 2, false); // Earth orbit
                ctx.stroke();

                ctx.drawImage(sun, 0, 0, 800, 800);

                window.requestAnimationFrame(draw);
            }

            init();

        &lt;/script&gt;

    &lt;/body&gt;

&lt;/html&gt;

</code></pre>
<p dir="auto"><strong>images folder</strong><br />
<img src="https://i.imgur.com/yPhQ79g.png" alt="c513141f-d0e8-47e0-b866-045535ab5ee1-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="https://i.imgur.com/3h1hWnZ.png" alt="183cd962-9200-45ca-8868-cc3297b420b2-image.png" class=" img-fluid img-markdown" /><br />
<strong>images:</strong><br />
<img src="https://i.imgur.com/Wyz0oei.png" alt="canvas_sun.png" class=" img-fluid img-markdown" /> <img src="https://i.imgur.com/9ZXuk2E.png" alt="canvas_moon.png" class=" img-fluid img-markdown" /> <img src="https://i.imgur.com/WIeofmL.png" alt="canvas_earth.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.secnto.com//post/5755</link><guid isPermaLink="true">https://community.secnto.com//post/5755</guid><dc:creator><![CDATA[zaasmi]]></dc:creator><pubDate>Tue, 21 Jul 2020 08:53:12 GMT</pubDate></item></channel></rss>