Introduction
This is a simple application for beginners that shows how to create an interactive flower on a canvas using HTML5. We know that HTML 5 is the advanced version of HTML. HTML 5 can be used to develop 3D applications. This article is intended to help with the use of HTML5 tools to develop an interactive flower on a canvas application. <canvas> is an HTML element which can be used to draw graphics using scripting. It can be used to draw graphs to make photo compositions or do simple animations. The <canvas> element is a bitmap drawing API and once you have committed to a set of pixels you are stuck with them. 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 create an interactive flower on a canvas using HTML5 tools.
Step 1. First, open an HTML editor such as Notepad.
- Open start->Notepad.
- The name of the editor is "canvas".

Step 2. Create a folder on a desktop.
- Right-click on desktop->new->Folder.
- The name of the folder is "Tom".
\
Step 3. Open Visual Studio.
- Go to file -> New->Projects.
- Crete an ASP. NET Web Application.
- Name of "Flower.aspx".


Step 4. Add an HTML file to your web application.
- Right-click on Solution Explorer.
- Add->add new item->HTML form.
- The Name of the HTML form is "Demo.html".

Step 5. Now in this step, we define a function named drawling(). This function opens or closes a path and defines the height and width of a flower.
Code
function drawLine(Flower, lineLayer) {
var stage = Flower.getStage();
var ctx = lineLayer.getctx();
ctx.save();
ctx.beginPath();
lineLayer.clear();
ctx.strokeStyle = "green";
ctx.lineWidth = 10;
ctx.moveTo(Flower.x, Flower.y);
ctx.lineTo(stage.width / 2, stage.height + 10);
ctx.fill();
ctx.stroke();
ctx.closePath();
ctx.restore();
}
Step 6. Now in this step we set a center of a flower and set a color of a mouse over and mouse down event.
Code
window.onload = function () {
var stage = new Kinetic.Stage("container", 578, 200);
var FlowerLayer = new Kinetic.Layer();
var lineLayer = new Kinetic.Layer();
var Flower = new Kinetic.Group();
var center = new Kinetic.Circle({
x: 0,
y: 0,
radius: 20,
fill: "yellow",
stroke: "black",
strokeWidth: 4
});
center.on("mousedown", function () {
Flower.draggable(true);
document.body.style.cursor = "pointer";
});
center.on("mouseover", function () {
this.setFill("orange");
FlowerLayer.draw();
});
center.on("mouseout", function () {
this.setFill("yellow");
FlowerLayer.draw();
});
}




Manoj Singh PanwarPosted Feb 28, 2012, 5:05 AM
You have done well but can you please tell why have you mentioned notepad and a folder named *TOM* in step 1 when you have not used it anywhere or if you have used it please mention. it. Thank you for your valuable effort.
Akash GaurPosted Feb 26, 2012, 10:56 PM
hello manish . you have done the work nicely.