Draw Polygon In TypeScript
In this article, we draw a polygon in a web application using TypeScript.
First, we download some files in the following attachment:
-
Kinect.d.ts
-
Kinectic.min.js
These files are added to the project. Then use the following procedure.
Step 1
Open Visual Studio 2012 and click "File" -> "New" -> "Project...". A window is opened. In this window, click "HTML Application for TypeScript" under Visual C#.
Give the name of your application as "Draw_Polygon" and then click "Ok".
Step 2
After this session the project has been created; a new window is opened on the right side. This window is called the Solution Explorer. The Solution Explorer contains the ts file, js file, CSS file, and aspx page.

Coding
Draw_Polygon.ts
- class Draw_Ploygon {
- Polygon() {
- var stage = new Kinetic.Stage({
- container: 'content'
- });
- var layer = new Kinetic.Layer();
- var poly = new Kinetic.Polygon({
- points: [53, 192, 73, 160, 340, 23, 400, 109, 299, 139, 342, 93],
- fill: 'green',
- stroke: 'black',
- strokeWidth: 5
- });
- layer.add(poly);
- stage.add(layer);
- }
- }
- window.onload = () => {
- var obj = new Draw_Ploygon();
- obj.Polygon();
- }
Draw_Polygon_Demo.html


Comments
Join the conversation! Your thoughts help the community grow.