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 7671457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:03:44+00:00 2026-05-31T16:03:44+00:00

This is my svg code for instance. <rect x=1531.718 y=1688.217 opacity=0.8 fill=#FEE880 enable-background=new width=40.67

  • 0

This is my svg code for instance.

<rect x="1531.718" y="1688.217" opacity="0.8" fill="#FEE880" enable-background="new    " width="40.67" height="27"></rect>
            <rect x="1531.718" y="1661.217" opacity="0.8" fill="#F67B9E" enable-background="new" width="40.67" height="27"></rect>
            <rect x="1335.718" y="1053.356" opacity="0.8" fill="#FEE880" enable-background="new" width="236.67" height="153.01"></rect>
            <polygon opacity="0.8" fill="#F67B9E" enable-background="new    " points="1572.388,970.547 1572.388,1016.547 
                1509.718,1016.547               "></polygon>    

How can I get the position, width & height when a div is wrapped around a polygon in the svg. I prefer to use jQuery.

I did this for the “rect”s in the svg, it works like charm!:) Here’s the code:

 $('#mapArea').load('src/124/124.svg', function(){

    var inputs = $('#mapArea').find('rect');
    var inputsCount = inputs.size();

    for (i=1;i<inputsCount;i++){

        var positionX = $('#mapArea').find('rect:eq('+i+')').attr('x');
        var positionY = $('#mapArea').find('rect:eq('+i+')').attr('y');
        var width = $('#mapArea').find('rect:eq('+i+')').attr('width');
        var height = $('#mapArea').find('rect:eq('+i+')').attr('height');
        $('#mapArea').after('<div style="position:absolute;width:'+width+'px;height:'+height+'px;background:rgba(0,0,0,0.4);top:'+positionY+'px;left:'+positionX+'px;">');

    }    

I could not do it like the rect, because for polygons there’s only one attr… POINTS!

  • 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-05-31T16:03:45+00:00Added an answer on May 31, 2026 at 4:03 pm

    Please have a look at this fiddle http://jsfiddle.net/SLJp4/. In this fiddle, the square is a polygon. To continue, press the “scale the polygon” button(scroll a page a bit to see the button). The red fading div is in body. This red colored div will change its shape and position as you scale and translate the polygon using the button provided.

    To explain the code:

    tl – top left point of the polygon’s bounding box(in usr coordinate).

    br – bottom right point of the polygon’s bounding box(in usr coordinate).

    we shift these points to global user coordinate by

    tl = tl.matrixTransform(matrix)
    

    and br = br.matrixTransform(matrix)

    One thing i need is “how to calculate the 2 in width = (br.x – tl.x) * 2 programatically”. Where “2” is 400px/200.

    Then we are offseting the red div to the calculated points.

    note: I could not paste the scripts in the js portion of the fiddle window (throwing error), so pasted it in the html portion itself.

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

Sidebar

Related Questions

I have this svg: <circle cx=50 cy=100 r=50 stroke-width=0 fill=orange/> <polygon points=0,100, 50,50 100,100
I'm using this: http://code.google.com/p/svg-edit/ I put a hard coded code inside the svgcanvas div
I'm creating an SVG path using the Raphael library and the following code: this.resultsBoxLine1
I have a sample code like this <svg id=id1> <element1> </element1> <element2> </element2> </svg>
I have code like this: <span> <svg height=32 version=1.1 width=32 xmlns=http://www.w3.org/2000/svg style=overflow: hidden; position:
I have a code in SVG: <svg width=100% height=100% version=1.1xmlns=http://www.w3.org/2000/svg> <rect x=20 y=20 width=250
We display SVG images in MediaWiki using a template with this code: {{#tag:svgfile||src={{{1}}}|height={{{height|300px}}}|width={{{width|600px}}}}} where
I got this SVG image from Wikipedia and embedded it into a website using
CSS: img{ max-height:30px; } HTML: <img src=foo.svg /> I am looking for this svg
Consider this simple SVG file : <svg xmlns=http://www.w3.org/2000/svg xmlns:x=http://www.w3.org/1999/xlink viewBox=0 0 353 150> <defs>

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.