การวาดรูปทรงสี่เหลี่ยมด้วย KineticJS

เพื่อที่จะสร้างรูปทรงสี่เหลี่ยมด้วย KineticJS นั้น  เราจะใช้ Kinetic.Rect() ครับ. สำหรับรายละเอียดวิธีการใช้แอตทริบิวต์และเมธอดสามารถดูได้จากที่นี่ครับ API Document : http://kineticjs.com/docs/Kinetic.Rect.html

ตัวอย่าง แทคที่ใช้
ตัวอย่าง : วาดรูปทรงสี่เหลี่ยม
      var stage = new Kinetic.Stage({
        container: 'container',
        width: 578,
        height: 200
      });

      var layer = new Kinetic.Layer();

      var rect = new Kinetic.Rect({
        x: 239,          // กำหนดแนวแกน x
        y: 75,           // กำหนดแนวแกน y
        width: 100,      // กำหนดความกว้าง
        height: 50,      // กำหนดความสูง
        fill: 'blue',    // ใส่สีพื้น
        stroke: 'black', // กำหนดสีเส้น
        strokeWidth: 4   // กำหนดขนาดเส้น
      });

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

      // add the layer to the stage
      stage.add(layer);

ผลลัพธ์ที่ได้คือ

About Nop

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment