admin管理员组文章数量:1353265
I am working on a fabric js application & i need work with measurement units like inches & mm
I tried this code & it display blank
So my question is how work with units like inch & mm in fabric js
a = new fabric.Rect({
top:0,
left:0 ,
fill: '#000',
width: 50mm,
height: 50mm,
});
b = new fabric.Rect({
top:0,
left:200,
fill: '#000',
width: 1in,
height: 1in,
});
canvas.add(a, b);
<canvas id='canvas' width="500" height="400" style="border:#000 1px solid;"></canvas>
I am working on a fabric js application & i need work with measurement units like inches & mm
I tried this code & it display blank
So my question is how work with units like inch & mm in fabric js
a = new fabric.Rect({
top:0,
left:0 ,
fill: '#000',
width: 50mm,
height: 50mm,
});
b = new fabric.Rect({
top:0,
left:200,
fill: '#000',
width: 1in,
height: 1in,
});
canvas.add(a, b);
<canvas id='canvas' width="500" height="400" style="border:#000 1px solid;"></canvas>
Share
Improve this question
asked Nov 2, 2015 at 10:46
DineshDinesh
8652 gold badges19 silver badges41 bronze badges
1 Answer
Reset to default 11fabricjs works in pixels. There is a function: fabric.util.parseUnit() that can parse inches, mm, pixels, points.
a = new fabric.Rect({
top:0,
left:0 ,
fill: '#000',
width: fabric.util.parseUnit('50mm'),
height: fabric.util.parseUnit('50mm'),
});
b = new fabric.Rect({
top:0,
left:200,
fill: '#000',
width: fabric.util.parseUnit('1in'),
height: fabric.util.parseUnit('1in'),
});
canvas.add(a, b);
本文标签: javascriptHow to work with units like inch amp mm in fabric jsStack Overflow
版权声明:本文标题:javascript - How to work with units like inch & mm in fabric js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743896389a2557862.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论