嗨,我对pixijs很陌生(pixi.js - v5.2.4),我在pixijs网站上看到了一些样本,添加了一个简单的滑块,通过改变滑块值,多边形顶点的位置将得到改变我的代码。
var el = document.getElementById('slider');
if (el) {
el.addEventListener('input', changePolygon);
console.log("Great!!")
}
else{
console.log("It's null!!")
throw new ReferenceError("missingElement is not defined");
}
函数处理程序:
function changePolygon(e){
graphics.clear();
var target = (e.target) ? e.target : e.srcElement;
console.log(target.value)
// draw polygon
// flat array of numbers that will be interpreted as [x,y, x,y, ...],
let path = [300, 370,
500, 370,
500, 420,
target.value, 420];
graphics.lineStyle(outline_thicknes, outline_color, 1);
graphics.beginFill(0x650A5A);
graphics.drawPolygon(path);
graphics.endFill();
}
但是由于某些原因,多边形的轮廓看起来不太好,能不能有人看看,并建议我如何解决这个问题。
谢谢
发布于 2020-06-09 14:31:47
显然,我忘了用target.value
包parseFloat,因为target.value
是字符串类型的。
现在它工作得很好!
https://stackoverflow.com/questions/62176069
复制相似问题