Create a ruler of guides and grids with fabric.js

Is there a way to create guides and grids using fabric.js like photoshop? I know a library for this purpose: http://mark-rolich.github.io/RulersGuides.js/

But I want to apply rulers and guides to Div. So, is there any other library or fabricJs code snippet for this?

Thank.

+3


source to share


1 answer


There's a ruler demo here in fabricjs: https://jsfiddle.net/grqorhqw/1/ . The main part is to add lines and text labels to the loop:



 window.canvas.add(new fabric.Line([measurementThickness - tickSize, location1, measurementThickness, location1], { stroke: '#888', selectable: false }));
    window.canvas.add(new fabric.Text(count + "\"", {
        left: measurementThickness - (tickSize * 2) - 7,
        top: location1,
        fontSize: 12,
        fontFamily: 'san-serif'
    }));

      

+1


source







All Articles