Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67441

Adding text labels depending on the position of the line

$
0
0

Good Day Stackoverflowers,

I'm creating a floor plan using canvas. I'm a bit stuck on the part of adding labels beside a line. It should be horizontally and vertically centered and placed outside of the line.

Here's what I'm trying to achieve.

enter image description here

This floorplan is composed of 4 lines. I wish to create a label for each lines depending on the number of lines.

this.floorplan.getWalls().forEach((wall) => {
    this.drawWall(wall);
});

private drawWall(wall: Wall) {
    var startX = wall.startX();
    var startY = wall.startY();
    var endX = wall.endX();
    var endY = wall.endY();

    this.context.beginPath();
    this.context.moveTo(startX, startY);
    this.context.lineTo(endX, endY);
    this.context.lineWidth = width;
    this.context.strokeStyle = color;
    this.context.stroke();

    // add labels here
    var label = wall.getLabel();
}

Hope someone could shed a light.

Thank you.


Viewing all articles
Browse latest Browse all 67441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>