Mor*_*ran 5 jquery frontend canvas web-frontend fabricjs
我在这里搜索 fabricJS-circle,但没有发现有一种方法可以添加数字 1 或 2 或 3 之类的文本......在画布上的圆圈内?
这是我在画布上的圆对象:
function makeStaion(left, top, stationID) {
var c = new fabric.Circle({
left: left,
top: top,
radius: 2,
fill: '#5afffa',
stroke: '#666',
selectable: true,
centeredScaling:true,
padding:2,
hasRotatingPoint: false,
borderColor: 'black',
cornerColor: 'black'
});
c.hasControls = true;
c.station = true;
c.stationID = stationID;
c.stationName = stations[stationID].name;
c.description = stations[stationID].desc;
c.image = stations[stationID].image;
return c;
}
Run Code Online (Sandbox Code Playgroud)
nic*_*ans 11
我想你要找的是一个面料组。
教程在这里:http : //fabricjs.com/fabric-intro-part-3#groups
文档在这里:http : //fabricjs.com/docs/fabric.Group.html
尝试这样的事情:
var c = new fabric.Circle({
left: left,
top: top,
radius: 2,
fill: '#5afffa',
stroke: '#666',
selectable: true,
centeredScaling:true,
padding:2,
hasRotatingPoint: false,
borderColor: 'black',
cornerColor: 'black'
});
var t = new fabric.Text(stationID, {
fontFamily: 'Calibri',
fontSize: 1.2,
textAlign: 'center',
originX: 'center',
originY: 'center',
left: LayoutCoordX(STA),
top: LayoutCoordY(BL-BLOffset)-radius-.4
});
var g = new fabric.Group([c, t],{
// any group attributes here
});
g.hasControls = true;
g.station = true;
g.stationID = stationID;
g.stationName = stations[stationID].name;
g.description = stations[stationID].desc;
g.image = stations[stationID].image;
return g;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6930 次 |
| 最近记录: |