Linear Pointer Changing Various Effect Using HTML5

Introduction

 
In this article we are going to understand a topic related to the designing; the scenario for this is Linear Pointer changing various effects. In this part, you can select from various options and as you press the action button the pointer begins moving along dedicated points. Here we will use some JavaScript and some styles along with the HTML code. Just go through the steps to see how to create this application. Let's see how the linearpointer application can be created. To do so go through the following steps.
 
Step 1 : Open a HTML editor or Visual Studio.
 
sd.gif
 
Open File menu ->select new ->Choose Website then.
 
0000.jpg
 
This is where we will create a HTML5 application.
  • Go to Solution Explorer
  • Right-click on the Application name
  • Select Add-->add new item
  • Now in the window that opens, select an HTML page or new Web form
  • Rename it to LINEARPOINTER.aspx
lt.gif
 
Step 2: In this section we will create the style for the media and create the .css on the media screen. Put the given script in the Head section of the HTML or in between the <head>--</head> tags.
 
Here two CSS files are used for design purposes; one is for the section div, named d1.css and the other d2.css for the whole body of the web page.
 
d1.css scripting
  1. body    
  2. {    
  3.    background#00688B;    
  4.     color#fff;    
  5.     font300 100.1% "Helvetica Neue" , Helvetica"Arial Unicode MS" , Arialsans-serif;    
  6. }    
  7. #holder    
  8. {    
  9.     height442px;    
  10.     left: 42%;    
  11.     margin-240px 0 0 -320px;    
  12.     positionabsolute;    
  13.     top: 57%;    
  14.     width842px;    
  15.     font-sizex-large;    
  16.     background-color#008000;    
  17. }    
  18. #duplicate {    
  19.     bottom: 0;    
  20.     font300 .7em "Helvetica Neue"Helvetica, ;    
  21.     positionabsolute;    
  22.     right: 1em;    
  23.     text-alignright;    
  24. }    
  25. #duplicate d {    
  26.     color#fff;    
  27. }   
d2.css scripting
  1. body {  
  2.     background#fff;  
  3.     color#000;  
  4.     font100.1% "Comic Sans MS", Lucida, Verdanasans-serif;  
  5. }  
  6. #holder {  
  7.     height480px;  
  8.     left: 50%;  
  9.     margin0 0 0 -320px;  
  10.     positionabsolute;  
  11.     top: 0;  
  12.     width640px;  
  13. }  
  14. #duplicate {  
  15.     bottom: 0;  
  16.     font-size: .7em;  
  17.     positionabsolute;  
  18.     right: 1em;  
  19.     text-alignright;  
Step 3: In this part, we need to work on some JavaScript. To fully understanding how the JavaScript works download the attached .rar file and run the linearpointer application. The whole JavaScript looks as in the following.
  1. Color(function ()  
  2.        {  
  3.             var r = Color("holder"),  
  4.             choice = document.getElementById("choice"),  
  5.             choice1 = document.getElementById("choice1"),  
  6.             run = document.getElementById("execute"),  
  7.             set = r.set(r.circle(300, 200, 8), r.circle(200, 100, 8), r.circle(100, 200, 8), r.circle(200, 300, 8), r.circle(200, 200, 8)).attr({ stroke: "none", fill: "#666" }),  
  8.             c = r.circle(200, 200, 10).attr({ stroke: "#fff""stroke-width": 4 }),  
  9.             fade = function (id)  
  10.                    {  
  11.                      return function ()  
  12.                     {  
  13.                       set[id].attr({ fill: "#fff", r: 12 }).animate({ fill: "#666", r: 8 }, 500);  
  14.                     };  
  15.                    };  
  16.                    run.onclick = function ()  
  17.                      {  
  18.                       var ex = choice.value,  
  19.                           ey = choice1.value;  
  20.                       c.stop().animate({  
  21.                       "20%": { cy: 200, easing: ey, callback: fade(0) },  
  22.                       "40%": { cy: 100, easing: ey, callback: fade(1) },  
  23.                       "60%": { cy: 200, easing: ey, callback: fade(2) },  
  24.                       "80%": { cy: 300, easing: ey, callback: fade(3) },  
  25.                       "100%": { cy: 200, easing: ey, callback: fade(4) }  
  26.                    }, 5000).animate({  
  27.                       "20%": { cx: 300, easing: ex },  
  28.                       "40%": { cx: 200, easing: ex },  
  29.                       "60%": { cx: 100, easing: ex },  
  30.                       "80%": { cx: 200, easing: ex },  
  31.                       "100%": { cx: 200, easing: ex }  
  32.                     }, 5000);  
  33.                 };  
  34.             }); 
Step 4 : In this section we are going to become familiar with the body part of HTML scripting. Replace this script from the body section of the LINEARPOINTER.aspx page. Here we pass a #holder in the div id that is defined in the d1.css file.
  1. <body>  
  2.     <center>  
  3.     <h2>LINEARPOINTER MOVING</h2>  
  4.     <hr />  
  5.         <div id="holder"></div>  
  6.         <div id="form">  
  7.             <select id="choice">  
  8.                 <option value="">Linear</option>  
  9.                 <option value=">">Ease In</option>  
  10.                 <option value="<">Ease Out</option>  
  11.                 <option value="<>">Ease In and Out</option>  
  12.                 <option value="bounce">Bounce</option>  
  13.                 <option value="elastic">Elastic</option>  
  14.                 <option value="backIn">Back In</option>  
  15.                 <option value="backOut">Back Out</option>  
  16.             </select>  
  17.             <select id="choice1">  
  18.                 <option value="">Linear</option>  
  19.                 <option value=">">Ease In</option>  
  20.                 <option value="<">Ease Out</option>  
  21.                 <option value="<>">Ease In and Out</option>  
  22.                 <option value="bounce">Bounce</option>  
  23.                 <option value="elastic">Elastic</option>  
  24.                 <option value="backIn">Back In</option>  
  25.                 <option value="backOut">Back Out</option>  
  26.             </select>  
  27.             <button id="execute">Action Button</button>  
  28.         </div>  
  29.         </center>  
  30.     </body> 
Step 5 : The complete code for the linearpointer application is:
  1. <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="LINEARPOINTER.aspx.cs" Inherits="_Default" %>  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4. <head runat="server">  
  5.    <meta charset="utf-8">  
  6.         <title></title>  
  7.         <link rel="stylesheet" href="d1.css" media="screen">  
  8.         <link rel="stylesheet" href="d2.css" media="print">  
  9.         <style media="screen">  
  10.             #holder {  
  11.                 height: 400px;  
  12.                 margin: -200px 0 0 -200px;  
  13.                 width: 400px;  
  14.             }  
  15.             #form {  
  16.                 position: absolute;  
  17.                 top: 50%;  
  18.                 left: 50%;  
  19.                 width: 400px;  
  20.                 height: 100px;  
  21.                 margin: -200px 0 0 -200px;  
  22.             }  
  23.         </style>  
  24.         <script src="javascript.js"></script>  
  25.         <script>  
  26.         </script>  
  27.     </head>  
  28.     <body>  
  29.     <center>  
  30.     <h2>LINEARPOINTER MOVING</h2>  
  31.     <hr />  
  32.         <div id="holder"></div>  
  33.         <div id="form">  
  34.             <select id="choice">  
  35.                 <option value="">Linear</option>  
  36.                 <option value=">">Ease In</option>  
  37.                 <option value="<">Ease Out</option>  
  38.                 <option value="<>">Ease In and Out</option>  
  39.                 <option value="bounce">Bounce</option>  
  40.                 <option value="elastic">Elastic</option>  
  41.                 <option value="backIn">Back In</option>  
  42.                 <option value="backOut">Back Out</option>  
  43.             </select>  
  44.             <select id="choice1">  
  45.                 <option value="">Linear</option>  
  46.                 <option value=">">Ease In</option>  
  47.                 <option value="<">Ease Out</option>  
  48.                 <option value="<>">Ease In and Out</option>  
  49.                 <option value="bounce">Bounce</option>  
  50.                 <option value="elastic">Elastic</option>  
  51.                 <option value="backIn">Back In</option>  
  52.                 <option value="backOut">Back Out</option>  
  53.             </select>  
  54.             <button id="execute">Action Button</button>  
  55.         </div>  
  56.         </center>  
  57.     </body>  
  58. </html> 
Step 6: Output Press F5 Note: For the accurate output of HTML5 applications, you must have the Google Chrome browser in your PC. You will see we rotated the image while the image is displaying in the browser.
 
lt2.gif
 
Select your choices.
 
lt4.gif
 
After changing the options you will see.
 
lt5.gif
 
Here are some useful resources.