Introduction
This is a simple application for beginners that help show how to rotate a photo on canvas using HTML 5 and CSS tools. We know that HTML 5 is the advanced version of HTML. Basically HTML 5 can be used to develop 3D applications. This article is intended to help with the use of HTML5 tools to develop a photo on canvas application. CSS is the acronym for Cascading Style Sheet that is used for design. CSS defines how HTML elements are to be displayed. Canvas is an important tag of an HTML 5 that is used to show the image and text in an HTML 5 application. I hope this article helps to show how to rotate a photo on canvas using HTML 5 and CSS tools.
Step 1: First Open an HTML editor such as Notepad.
- Open start->Notepad.
- The name of the editor is "canvas".

- Right-click on desktop->new->Folder.
- The name of the folder is "photo".

- Go to file -> New->Projects.
- Create an ASP. NET Web Application.
- Name of "Tom.aspx".


- Right-click on Solution Explorer.
- Add->add new item->HTML form.
- The Name of the HTML form is "Image.html".

- Right-click of Solution explorer.
- add->add folder.
- The name of the folder is "image".

Code
- < script src = "Scripts/canvas.js"
- type = "text/javascript" > < /script> <
- script src = "Scripts/canvas2.js"
- type = "text/javascript" > < /script>
Code
Step 8: In this step set a canvas length and add an image according to image id.
- <style type="text/css" media="screen">
- can.resize-ne { cursor: ne-resize; }
- can.resize-se { cursor: se-resize; }
- can.resize-sw { cursor: sw-resize; }
- can.resize-nw { cursor: nw-resize; }
- can.move { cursor: move; }
- can.default { cursor: default; }
- img { display: block; visibility: hidden; position: absolute; top: -1000; left: -1000; }
- input { margin-left: 20px; }
- fieldset { width: 480px; float: left; }
- .fieldset { width: 400px; float: left; }
- #ft { background-color: #eee; height: 70px; width: 99%;top: 0; left: 0; }
- #ft span { width: 100%; }
- </style>
Code
Step 9: Now set the click event of the set, erase and cover checkbox; after click they all of performing an action.
- can = new Canvas.Element();
- can.init('canvid1', { width: rex.getViewportWidth() - 5, height: rex.getViewportHeight() - 5 });
- img[img.length] = new Canvas.Img('img1', {});
- img[img.length] = new Canvas.Img('img2', {});
- img[img.length] = new Canvas.Img('img3', {});
- img[img.length] = new Canvas.Img('img4', {});
- img[img.length] = new Canvas.Img('img4', {});
- can.addImage(img[0]);
- can.addImage(img[1]);
- can.addImage(img[2]);
- can.setCanvasBackground(img[3]);
- can.addImage(img[4]);
- this.initEvents();
- }
Code
Step 10: Now in this step set a body of the canvas web page.
- initEvents: function ()
- {
- ctx.on('togglebg', 'click', this.toggleBg, this, true);
- ctx.on('S1', 'click', this.S1, this, true);
- ctx.on('T1', 'click', this.T1, this, true);
- ctx.on('T3', 'click', this.T3, this, true);
- ctx.on('T2', 'click', this.T2, this, true);
- }

Code
- <body id="canvasdemo" onload="" bgcolor="#ffccff">
- <canvas id="canvid1" ></canvas>
- <img id="img4" src="image/1.jpg" />
- <img id="img1" src="image/2.jpg" />
- <img id="img2" src="image/6.jpg" />
- <img id="img3" src="image/7.jpg" />
- <div id="ft">
- <div class="fieldset">
- </div>
- <fieldset>
- <legend style="background-color: #008080">Image</legend>
- <span style="background-color: #FF9999">
- <input type="checkbox" name="some_name" value="" id="T1" />Erase
- </span>
- <span style="background-color: #99FF99">
- <input type="checkbox" name="some_name"
- value="" id="T3" style="background-color: #FFCCFF" />Cover
- </span>
- <span style="background-color: #99FFCC">
- <input type="checkbox" name="some_name" value="" id="T2" />Set
- </span>
- </fieldset>
- <span style="background-color: #FF99FF">
- <input type="checkbox" name="some_name" value="" id="S1" /> Cover show
- <span>
- </div>
- </body>
Output




Resources
Here is some useful resource :

Join the conversation! Your thoughts help the community grow.