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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:19:54+00:00 2026-06-11T16:19:54+00:00

at the moment i am working with svg graphics to display a map of

  • 0

at the moment i am working with svg graphics to display a “map” of a splice.
When i try to draw rectangles or paths with a pattern (image) as a background, the pattern won’t use the local coordinate system of the drawn rect/path, but the global one.

This is how i define a pattern in the svg-document:

<defs>
    <pattern preserveAspectRatio="true" patternUnits="userSpaceOnUse" height="24" width="50" y="0" x="0" id="black_h">
         <image height="24" width="50" y="0" x="0" xlink:href="http://newlini.lokal/img/svg/black_h.png"/>
    </pattern>
</defs>

This is how i apply the pattern to a path:

<path style="fill: url(#black_h)" d="M324 0 L324 375 L348 375 L348 0">

So the behaviour i would expect is, that the pattern starts at the top left corner of the path and repeats itself in both directions. But in my example the pattern starts at the top left corner of the svg document, so the path only looks good, when the y-coord is a multiple of 24.

Do you have any idea where i am stucked?

Thanks in advance,

Tobi

EDIT1:

Here is a little example of my problem on jsfiddle:
http://jsfiddle.net/E3wBn/

EDIT2:

I used the advice from robertc and changed my example svg to this:

http://jsfiddle.net/2DKXn/

I also uploaded an example jpg which shows how it should look like later.

http://www.img-share.net/uploads/oi1IcdPBVk.jpg

  • 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-11T16:19:55+00:00Added an answer on June 11, 2026 at 4:19 pm

    The relevant attribute and value is patternContentUnits="objectBoundingBox", but it may not do exactly what you expect. When you specify this value you have to adjust the co-ordinates you’re using to something like this:

    <defs>
        <pattern preserveAspectRatio="true" patternContentUnits="objectBoundingBox" height="0.5" width="1" y="0" x="0" id="black_h">
             <image height="0.5" width="1" y="0" x="0" xlink:href="http://newlini.lokal/img/svg/black_h.png"/>
        </pattern>
    </defs>
    

    Everything will then get scaled back up to fit into the object it’s applied to. I don’t have access to the image you used so I wasn’t able to test the above code directly, but I made this similar example. Note that with this approach you basically end up with a fixed number of repetitions rather than a fixed sized image tiling.

    There’s a longer write up of SVG patterns on Mozilla Developer Network, I put two examples from that article into this JSFiddle to allow for easy experimentation.

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

Sidebar

Related Questions

I'm working on an image gallery at the moment and its doing something very
I am making an animated SVG donut chart. My best try for the moment
At the moment I am working on an on screen display project with black,
I am working on a iPad ordering web app at the moment which consists
I'm working on an MVC3 site at the moment, locally in IIS Express and
Working on a bunch of forms at the moment and I'm finding that I
For the moment we're still working with the 2.0 framework and and although 2.0
I'm working on a web service at the moment and there is the potential
I'm working with a good quality usb camera at the moment. The video quality
I am working on a project at the moment that requires a dialog box

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.