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

206
Visualizações
Arc function not working properly after canvas is resized

I am running a processing js program in a webpage, using the canvas to draw my game. I have overwritten some of the functions in javascript so I can use degrees as an input to the processing js functions.

This works perfectly, and allows me to input degrees for my arcs. The only time it does not work, however, is after I resize the canvas when the window is resized. It seems to switch back to using radians for the arc. Why is this? What implications does resizing the canvas suddenly create when it is done by the user?

<script>
  
var canvas = document.getElementById("canvas");
var processing = new Processing(canvas, function(processing) {
    
    var aspectRatio = {
        xFactor: 16,
        yFactor: 9
    };
    
    resizeCanvas = function() {
        var gameCanvas = {
            x: 0,
            y: 0,
            w: aspectRatio.xFactor,
            h: aspectRatio.yFactor
        };
        var resizing = true;
        while(resizing === true){
            gameCanvas.w++;
            gameCanvas.h=gameCanvas.w*(aspectRatio.yFactor/aspectRatio.xFactor);
            if(gameCanvas.w>=window.innerWidth||gameCanvas.h>=window.innerHeight){
                resizing = false;
            }
        }
        
        processing.size(gameCanvas.w,gameCanvas.h);
        
    }
  
    resizeCanvas();
    window.addEventListener('resize', resizeCanvas, false);
    processing.background(0xFFF);

    var arcFn = processing.arc;
    processing.arc = function(x,y,w,h,startAngle,stopAngle) {
        return arcFn(x,y,w,h,processing.radians(startAngle),processing.radians(stopAngle));
    }
    var showAdd = false;
    
    with (processing) {

        //Processing js code and program:

I tried re-overwriting the arc function everytime the canvas is resized with the window, but this caused the whole game to not work.

Any ideas for why this may be is appreciated.

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