Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!