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
Creating a custom shape in konva.js using path2d?

Using d3 for some shape calculations, then drawing with Konva.js. Creating a new shape from a svg path string. The shape is drawn, but fillStrokeShape doesn't seem to apply any styles.

The documentions says:

We can use the renderer to access the HTML5 Canvas context, and to use special methods like context.fillStrokeShape(shape) which automatically handles filling, stroking, and applying shadows.

I am guessing this is the case because the path gets drawn using stroke() or fill().

let res = 'M-258.4308858485627,28.5215223914706A260,260,0,0,1,-241.23905423140914,-96.97277305272468Q0,0,-258.4308858485627,28.5215223914706Z' 
    let shape = new Konva.Shape({
        stroke: 'blue',
        fill: 'green',
        strokeWidth: 1,
        rotation: 90,
        sceneFunc: function (ctx, shape) {   
          ctx.beginPath()

          ctx.stroke(new Path2D(res))
        
    
          ctx.fillStrokeShape(shape)
        }
      })

Possible solution would be to convert the svg path string into canvas instructions, then use context.moveTo, etc ... draw the path. But using Path2D should already do this for you.

Anyone know why fillStrokeShape is not working?

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

0

See docs of konvajs:

https://konvajs.org/docs/shapes/Path.html https://konvajs.org/docs/shapes/Custom.html

I think Path2D is not needed.

Insert your res in Konva.Path.data

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