gpt4 book ai didi

javascript - 如何在 kineticjs v4.0.5 中显示图像周围的边框

转载 作者:行者123 更新时间:2023-11-29 20:03:11 26 4
gpt4 key购买 nike

Kineticjsv4.0.5默认不支持图片边框,所以.showBorder().hideBorder()会报错

Uncaught TypeError: Object # has no method 'showBorder'

但是当我包含 Image Plugin v1.0.1 javascript 文件时,我的游戏根本没有出现,而 FireBug 也没有报告任何错误。

我也开始了 issue在 github 上。

问候,

最佳答案

试试这段代码

<!DOCTYPE HTML>
<html>
<head>
<script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.0.5.js"></script>

<script>
window.onload = function() {
var stage = new Kinetic.Stage({
container: "container",
width: 578,
height: 200
});
var layer = new Kinetic.Layer();

var imageObj = new Image();
imageObj.onload = function() {
var yoda = new Kinetic.Image({
x: 140,
y: stage.getHeight() / 2 - 59,
image: imageObj,
width: 106,
height: 118,
stroke:"Red",
strokeWidth:5
});

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

// add the layer to the stage
stage.add(layer);
yoda.on('mouseover', function() {
yoda.setStrokeWidth("Transparent");
yoda.setStroke(0);
layer.draw();
});
};
imageObj.src = "http://www.html5canvastutorials.com/demos/assets/yoda.jpg";
};
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>

关于javascript - 如何在 kineticjs v4.0.5 中显示图像周围的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13294038/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com