Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
save line as pixel in json in fabric.js

happy new year, dear colleagues! My goal is to create an app that logs the free drawing position using fabric.js in the console.log. Here is my application code:

var canvas = new fabric.Canvas(document.getElementById('canvasId'));
canvas.isDrawingMode = true;
canvas.freeDrawingBrush.width = 5;
canvas.freeDrawingBrush.color = '#00aeff';
  
canvas.on('path:created', function(e) 
{  
  e.path.set();
  canvas.renderAll();
  console.log(JSON.stringify(canvas));
});
  
canvas 
{
  border: 1px solid red;
}
<canvas id="canvasId" width="600" height="600"></canvas>

<script src="https://unpkg.com/fabric@4.6.0/dist/fabric.js"></script> 

the main problem is that this drawing is entered into the console only at the moment when the finger is lifted from the mouse button. As a result, in the case of using socket.io, you can observe the appearance of trailing lines. I do not need to enter data as json throughout the entire work with the mouse, so that the movement is transmitted without delays. How to solve this problem?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda