【发布时间】:2013-11-17 06:07:45
【问题描述】:
我想在 KineticJS 中创建一个复杂的形状。
我尝试了很多方法并搜索了很多,我得出的结论是我应该创建一个包含内容的新 Kinetic.Shape。但是当我这样做时,会创建形状但没有填充。
全是黑色的。
这是我的代码:
var complexShape = new Kinetic.Shape({
drawFunc: function(){
<?php include_once "script/dude.js" ?>
}
});
//Add the shape to the layer
layer.add(complexShape);
“dude.js”的部分内容:(整件事大约4000行)
var ctx = this.getContext();
// calque1/Groupe
ctx.save();
// calque1/Groupe/Groupe
ctx.save();
// calque1/Groupe/Groupe/Trac
ctx.save();
ctx.beginPath();
ctx.moveTo(325.6, 98.6);
ctx.bezierCurveTo(322.3, 86.4, 322.7, 73.7, 326.7, 60.6);
ctx.bezierCurveTo(317.3, 47.6, 309.7, 39.8, 303.7, 37.0);
ctx.bezierCurveTo(295.8, 42.3, 290.8, 61.0, 288.7, 93.1);
ctx.bezierCurveTo(283.5, 71.4, 282.5, 51.1, 285.7, 32.0);
ctx.bezierCurveTo(280.5, 22.3, 275.1, 14.8, 269.5, 9.5);
ctx.bezierCurveTo(265.6, 5.8, 261.7, 3.1, 257.6, 1.5);
ctx.bezierCurveTo(256.8, 4.1, 256.0, 6.8, 255.3, 9.5);
ctx.bezierCurveTo(249.2, 31.9, 247.5, 53.9, 250.1, 75.5);
ctx.lineWidth = 3.0;
ctx.strokeStyle = "rgb(75, 39, 111)";
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.stroke();
结果 Normal Canvas 与 KineticJS:
【问题讨论】: