Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
Why does a line drawn on the HTML5 Canvas completely fill up a monitor whose pixel resolutions are 25% higher?

On both of my PC monitors, when I draw a line from (0,0) to (window.innerWidth,window.innerHeight), the line fills the screen diagonally. However window.innerWidth and window.innerHeight are 20% less than the screen resolution specified by the monitor manufacturer and agreed with by the Windows 10 display information. Strangely enough, this wasn't the case 6 months ago when I first tested similar code. Any ideas?

<!doctype html>
<html  >  
<script type="text/javascript">  
window.addEventListener("load", windowLoadHandler, false);          
function windowLoadHandler() { init();}  // Is this still necessary? 
    function init() {   
    tC = document.getElementById("can1");           ctx = tC.getContext("2d");
    cw= tC.width =  window.innerWidth;      ch = tC.height = window.innerHeight;     
    ctx.fillStyle = "yellow";     ctx.fillRect(0,0,tC.width,tC.height);  
ctx.fillStyle = ctx.strokeStyle= "black"; ctx.font = "20pt Arial"; 
    ctx.fillText("Cwidth = " + cw + " ; Cheight = " +ch,200,300);   
    ctx.moveTo(0,0); ctx.lineTo(cw,ch); ctx.stroke();   
        }    
</script> 
<form>
<div >   <canvas id="can1" width= 50px  height = 50px  > </canvas>  </div>  
</form>
</html>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda