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

199
Visualizações
clear Canvas when using globalCompositeOperation = 'source-in'

I'm drawing a face in a canvas with a mask. the face is apearing only where the mask is full.

function drawface(){ this.ctx.globalCompositeOperation = 'source-in';
    this.ctx.drawImage(msk, 0, 0, msk_w, msk_w, x, marg, h_c, h_c );
    this.ctx.drawImage(this.face, 0, 0, w_f, h_f, x+x_offset, marg+y_offset, h_c, h_c);}

it's working fine, but I want to move the face on drag. So I need to reset the canvas, then redraw the face. But when I do

function resetCanvas(){
    this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
    }
    

I get a blank canvas, and the drawface function don't work any more after resetCanvas is called. I tried with save and reset too, but I couldn't find a working solution. Can any one help please? thanks !

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Needed to reset globalCompositeOperation after drawing the face.

this.ctx.globalCompositeOperation = 'source-over';
about 4 years ago · Juan Pablo Isaza Relatório
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