Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:58:24+00:00 2026-06-18T03:58:24+00:00

I want to make a rectangle knowing the position of the two vertical lines

  • 0

I want to make a rectangle knowing the position of the two vertical lines of the sides. The lines are implemented as follows:

<path fill="#000000" id="Measure1" d="M159.688,119.75L159.688,88.75L160.28799999999998,88.75L160.28799999999998,119.75ZM162.688,119.75L162.688,88.75L163.28799999999998,88.75L163.28799999999998,119.75Z"/>

<path fill="#000000" id="Measure2" d="M260.168,119.75L260.168,88.75L260.76800000000003,88.75L260.76800000000003,119.75Z"/>

With this code I have a rectangle:

<path d="M10 80 H 110 V 130 H   10 V  80 Z" fill="red" />

But can I use the coordinates of the two lines to use them to give my rectangle the position?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:58:25+00:00Added an answer on June 18, 2026 at 3:58 am

    You can get the bounding box of the lines with SVG’s native getBBox(), and then calculate the positions, here is a basic example:

    var path1 = document.getElementById("Measure1");
    var path2 = document.getElementById("Measure2");
    var xmlns = "http://www.w3.org/2000/svg";
    var svg = document.querySelector("svg");
    
    var bbox1 = path1.getBBox();
    var bbox2 = path2.getBBox();
    
    var x = bbox1.x + bbox1.width;
    var y =  bbox1.y;
    var width = bbox2.x - x;
    var height =  bbox1.height;
    
    var rect = document.createElementNS(xmlns, "rect");
    rect.setAttribute("x", x);
    rect.setAttribute("y", y);
    rect.setAttribute("width", width);
    rect.setAttribute("height", height);
    rect.setAttribute("fill", "red");
    svg.appendChild(rect);
    

    You can see the result here:

    http://jsfiddle.net/3rSYV/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want make a bash script which returns the position of an element from
I have a javafx pane and a rectangle inside it.. I want to make
I want to make an apps detect an square/rectangle in my webcam using EMGU
That's problem: I'm currently in OpenGL eye-space, now I want make a black rectangle
I want to make few or single side of rectangle to be resizable in
I want some way to make a given word bold(the first two characters of
I want to make a button style on Android with two background colors, such
I want to make a round rectangle in itextsharp. Here is the output I
I drew a square to the screen using Rectangle(), and I want to make
I want make datetimepicker in my project. Using jquery how it is possible? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.