Is there a way to insert lines into a rectangle?
For instance, if the rectangle has a height of 90 and I want to include 2 lines, it should look like this, see image here
However, currently it appears like this, see image here
I have two functions - one for creating lines and the other for creating rectangles. When I call the line function inside the rectangle function, the result is not as expected.
addLineToRectangle(){
console.log("activeObject", this.rect.width);
for (let i = 0; i < 2; i++) {
let line = new fabric.Line([0, 100, 90, 100], {
left: 1,
top: 30 * i,
stroke: 'red'
});
this.canvas?.add(line);
}
}
addRect(){
for (let i = 0; i < 1; i++) {
this.rect = new fabric.Rect( {
width: 90,
height: 90,
fill: 'transparent',
stroke: 'blue',
left: 1,
top: 90 * i,
});
this.canvas?.add(this.rect);
this.addLineToRectangle();
}
}