1 回答
TA贡献1812条经验 获得超5个赞
问题是,您通过元素的样式标签设置元素的宽度和高度。然而,这会导致画布元素出现问题。通常,高度和宽度属性用于实际大小调整,CSS宽度/高度用于缩放。
解决方案 变更
function newColorCanvas() {
var pick = document.createElement("DIV");
var canvas = document.createElement("canvas");
canvas.style.width = "200px";
canvas.style.height = "200px";
canvas.id = "wheelCanvas";
canvas.innerText = "Canvas tag not supported";
pick.appendChild(canvas);
var select = document.createElement("P");
select.id = "colorSelection";
select.innerText = "HSL: 135, 75, 50";
pick.appendChild(select);
document.getElementById("toolWindow").appendChild(pick);
paintCanvas(135,75,50);
canvas.addEventListener('click', function() {updateCanvas();});
}
到
function newColorCanvas() {
var pick = document.createElement("DIV");
var canvas = document.createElement("canvas");
canvas.width = 200;
canvas.height = 200;
canvas.id = "wheelCanvas";
canvas.innerText = "Canvas tag not supported";
pick.appendChild(canvas);
var select = document.createElement("P");
select.id = "colorSelection";
select.innerText = "HSL: 135, 75, 50";
pick.appendChild(select);
document.getElementById("toolWindow").appendChild(pick);
paintCanvas(135,75,50);
canvas.addEventListener('click', function() {updateCanvas();});
}
添加回答
举报