Kinetic.js(http://kineticjs.com/)

- 튜토리얼 사이트

   http://www.html5canvastutorials.com/kineticjs/html5-canvas-events-tutorials-introduction-with-kineticjs/


Kinetic은 HTML5 Canvas Framework입니다.

자칫 손이 많이 가는 작업이 될 수 있는 HTML5 Canvas의 작업을 편리하게 할 수 있도록 해줍니다.

지원 기능은 아래와 같습니다.


1. Shape

다양한 Shape 및 커스텀 Shape를 지원합니다.


2. Event

Desktop Web Browser의 이벤트 및 모바일 웹의 event 핸들링을 제공합니다.


3. Drag and Drop

간편하게 Drag&Drop을 구현할 수 있고 , Drag의 제약사항(바운더리 지정)을 간편하게 할 수 있습니다.


4. Layering

Layer 클래스를 이용하여 쉽게 여러 층으로 나눠진 그래픽을 그릴 수 있습니다.


5. Styling

채우기, 외곽선, 투명도, 그림자 등의 스타일링을 제공합니다.


이 외에 변환, 애니메이션, 데이터 시리얼라이즈, 선택자 등을 지원합니다.




코드 샘플

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>
    <script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.0.5.js"></script>
    <script>
      var stage = new Kinetic.Stage({
        container: 'container',
        width: 578,
        height: 200
      });

      var layer = new Kinetic.Layer();

      var rect = new Kinetic.Rect({
        x: 239,
        y: 75,
        width: 100,
        height: 50,
        fill: 'green',
        stroke: 'black',
        strokeWidth: 4
      });

      // add the shape to the layer
      layer.add(rect);

      // add the layer to the stage
      stage.add(layer);
    </script>
  </body>
</html>


결과



+ Recent posts