ตัวอย่าง แทคที่ใช้
1 2 | < div id = "container" > </ div > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | var stage = new Konva.Stage({ container: 'container' , width: 578, height: 200 }); var layer = new Konva.Layer(); var imageObj = new Image(); imageObj.onload = function () { var nop = new Konva.Image({ x: 140, //กำหนดจุดวาดตามแนวแกน x y: stage.getHeight() / 2 - 59, //กำหนดจุดวาดตามแนวแกน y image: imageObj, // อ็อปเจ็คของรูป width: 106, // ความกว้างของรูป height: 158 // ความสูงของรูป }); var filteredNop = new Konva.Image({ x: 320, //กำหนดจุดวาดตามแนวแกน x y: stage.getHeight() / 2 - 59, //กำหนดจุดวาดตามแนวแกน y image: imageObj, // อ็อปเจ็คของรูป width: 106, // ความกว้างของรูป height: 158 // ความสูงของรูป }); // เพิ่มรูปเข้าไปใน layer layer.add(nop); layer.add(filteredNop); // เพิ่ม layer เข้าไปใน stage stage.add(layer); // ทำ filter ให้เป็นสีเทาให้กับรูปที่สอง filteredNop.applyFilter(Konva.Filters.Grayscale, null , function () { layer.draw(); }); }; // กำหนดที่อยู่ของรูป |
ผลลัพธ์ที่ได้คือ
0 comments:
Post a Comment