Step 1: First open a HTML editor such as Notepad.
- Open start->Notepad.
- The name of editor is "Rotation".
Step 2: Create a folder on a desktop.
- Right-click on desktop->new->Folder.
- Name of folder is "Sam".
Step 3: Open Visual Studio.
- Go to file -> New->Projects.
- Crete an ASP. NET Web Application.
- Name of "Rectengle.aspx".
Step 4: Add a HTML file to your web application.
- Right-click on Solution Explorer.
- Add->add new item->HTML form.
- The Name of the HTML form is "Animation.html".
Step 5: Now in this step we set a style used to set a border and body of a canvas.
Code
<style type="text/css">
body
{
margin: 10px;
padding: 10px;
}
#myCanvas
{
border: 1px solid #00ff99;
background-color:Green;
}
</style>
Step 6: Now in this step we set a rectangle height width and set a color of a rectangle.
Code
var BR = new Kinetic.Rect(
{
x: 50,
y: 75,
width: 100,
height: 50,
fill: "#ff66ff",
stroke: "black",
strokeWidth: 4
});
var YR = new Kinetic.Rect({
x: 220,
y: 75,
width: 100,
height: 50,
fill: "#0000a0",
stroke: "black",
strokeWidth: 4,
centerOffset: {
x: 50,
y: 25
}
});
var RR = new Kinetic.Rect({
x: 400,
y: 75,
width: 100,
height: 50,
fill: "#ff8080",
stroke: "black",
strokeWidth: 4,
centerOffset: {
x: -100,
y: 0
}
});
Step 7: Now in this step we add a rectangle color on a layer.
Code
L.add(BR);
L.add(YR);
L.add(RR);
stage.add(L);
stage.onFrame(function (frame)
{
BR.rotate(Math.PI / 100);
YR.rotate(Math.PI / 100);
RR.rotate(Math.PI / 100);
L.draw();
});
Step 8: The demo of a complete application code is given below.
Code
<html>
<head>
<title>Tom application</title>
<style type="text/css">
body
{
margin: 10px;
padding: 10px;
}
#myCanvas
{
border: 1px solid #00ff99;
background-color:Green;
}
</style>
<script type="text/jscript" src="Scripts/JScript.js">
</script>
<script type="text/javascript">
window.onload = function ()
{
var stage = new Kinetic.Stage("container", 600, 300);
var L = new Kinetic.L();
var BR = new Kinetic.Rect(
{
x: 50,
y: 75,
width: 100,
height: 50,
fill: "#ff66ff",
stroke: "black",
strokeWidth: 4
});
var YR = new Kinetic.Rect({
x: 220,
y: 75,
width: 100,
height: 50,
fill: "#0000a0",
stroke: "black",
strokeWidth: 4,
centerOffset: {
x: 50,
y: 25
}
});
var RR = new Kinetic.Rect({
x: 400,
y: 75,
width: 100,
height: 50,
fill: "#ff8080",
stroke: "black",
strokeWidth: 4,
centerOffset: {
x: -100,
y: 0
}
});
L.add(BR);
L.add(YR);
L.add(RR);
stage.add(L);
stage.onFrame(function (frame)
{
BR.rotate(Math.PI / 100);
YR.rotate(Math.PI / 100);
RR.rotate(Math.PI / 100);
L.draw();
});
</script>
</head>
<body onmousedown="return false;" bgcolor="#400000">
<h1 style="background-color: #8080FF">Tom developed a Rotated Rectangle</h1>
<div id="container">
</div>
</body>
</html>
Step 9: Press Ctrl+ F5 to run the code in a browser.
Output
Resources
Here is some useful resources