KineticJS 中的 X 和 Y 坐标是相对于舞台的,而不是父 div 的页面 XY。
因此,您的路径图就在那里,它只是在后台哇-aaa-ay。
如果您将路径设置为适合舞台的比例和 x/y,您可以看到这一点:
var path = new Kinetic.Path({
data : "M176.0,463.0 L228.0,462.0 228.0,452.0 275.0,452.0 275.0,330.0 A40.0,0.0 0.0 1,1 254.0,295.0 L171.0,326.0 170.0,463.0z",
fill : 'rgba(100, 15, 56, 0.5)',
scale : .25,
x : 5,
y: 5
});
这是代码和小提琴:http: //jsfiddle.net/m1erickson/ZMDYy/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Prototype</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.5.4.min.js"></script>
<style>
#container{
border:solid 1px #ccc;
margin-top: 10px;
width:105px;
height:165px;
}
</style>
<script>
$(function(){
var stage = new Kinetic.Stage({
container: 'container',
width: 105,
height: 165
});
var layer = new Kinetic.Layer();
stage.add(layer);
var path = new Kinetic.Path({
data : "M176.0,463.0 L228.0,462.0 228.0,452.0 275.0,452.0 275.0,330.0 A40.0,0.0 0.0 1,1 254.0,295.0 L171.0,326.0 170.0,463.0z",
fill : 'rgba(100, 15, 56, 0.5)',
scale : .25,
x : 5,
y: 5
});
layer.add(path);
layer.draw();
}); // end $(function(){});
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>