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

196
Visualizações
How to draw a image instead of a color in canvas for Agar.io

I am currently making a clone of Agar.io based upon this I am stuck on getting skins to appear instead of the solid random color. With the current code, when you select a skin, making config.skin true, it freezes and I am not able to move, but can still chat. And I still have no image drawn.

config.skin is a base64 encoded image string

graph is the canvas's 2d context

    if (config.skin) {
      graph.strokeStyle = "hsl(" + userCurrent.hue + ", 100%, 45%)";
      graph.fillStyle = "hsl(" + userCurrent.hue + ", 100%, 50%)";
      graph.lineWidth = playerConfig.border;
      var skin = new Image();//userCurrent.x - 2 * userCurrent.size, userCurrent.y - 2 * userCurrent.size);
      skin.src = config.skin;
      skin.onload = () => { // jshint ignore:line
        graph.beginPath();
        graph.arc(userCurrent.h / 2, userCurrent.w / 2, userCurrent.radius, 0, Math.PI * 2, false);
        graph.clip();
        graph.drawImage(skin, userCurrent.x - 2 * userCurrent.size, userCurrent.y - 2 * userCurrent.size); //, 4 * userCurrent.size, 4 * userCurrent.size);
      };
    } else {
      graph.strokeStyle = "hsl(" + userCurrent.hue + ", 100%, 45%)";
      graph.fillStyle = "hsl(" + userCurrent.hue + ", 100%, 50%)";
      graph.lineWidth = playerConfig.border;
    }

full code at github

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