1 回答

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊
問題是,您通過元素的樣式標(biāo)簽設(shè)置元素的寬度和高度。然而,這會(huì)導(dǎo)致畫布元素出現(xiàn)問題。通常,高度和寬度屬性用于實(shí)際大小調(diào)整,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();});
}
添加回答
舉報(bào)