Introduction

In this article, we draw a Spline in HTML.
First, we download the file in the following attachment:
  1. Kinectic_beta.js
These files are added to the project, then use the following procedure.
Step 1
Open Visual Studio 2010 and click "File" -> "New" -> "Website...". A window is opened. In this window, give your application the name "Draw_Spline" and then click "Ok".
Step 2
Add the kinetic_beta.js file. 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 js file and HTML file.
solution-explorer.jpg
Coding
Draw_Spline.html
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. </head>
  6. <body>
  7. <h3> Draw Spline in HTML5 </h3>
  8. <div id="container"></div>
  9. <script src="Kinetic_beta.js" type="text/javascript"></script>
  10. <script>
  11. var stage = new Kinetic.Stage({
  12. container: 'container',
  13. width: 578,
  14. height: 200
  15. });
  16. var layer = new Kinetic.Layer();
  17. var blueSpline = new Kinetic.Spline({
  18. points: [{
  19. x: 93,
  20. y: 180
  21. }, {
  22. x: 240,
  23. y: 53
  24. }, {
  25. x: 500,
  26. y: 209
  27. }, {
  28. x: 350,
  29. y: 129
  30. }],
  31. stroke: '#0066FF',
  32. strokeWidth: 10,
  33. lineCap: 'round',
  34. tension: 1
  35. });
  36. var redSpline = new Kinetic.Spline({
  37. points: [{
  38. x: 173,
  39. y: 180
  40. }, {
  41. x: 370,
  42. y: 43
  43. }, {
  44. x: 500,
  45. y: 129
  46. }, {
  47. x: 300,
  48. y: 129
  49. }],
  50. stroke: '#663300',
  51. strokeWidth: 10,
  52. lineCap: 'round',
  53. tension: 0.5
  54. });
  55. var greenSpline = new Kinetic.Spline({
  56. points: [{
  57. x: 20,
  58. y: 50
  59. }, {
  60. x: 340,
  61. y: 50
  62. }, {
  63. x: 200,
  64. y: 150
  65. }, {
  66. x: 250,
  67. y: 150
  68. }],
  69. stroke: '#006600',
  70. strokeWidth: 5,
  71. lineCap: 'round',
  72. tension: 1,
  73. dashArray: [10, 10]
  74. });
  75. layer.add(blueSpline);
  76. layer.add(redSpline);
  77. layer.add(greenSpline);
  78. stage.add(layer);
  79. </script>
  80. </body>
  81. </html>
Output
spline.jpg
For more information, download the attached sample application.