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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:37:27+00:00 2026-06-11T14:37:27+00:00

I am creating a game in SVG and require square tiles to be placed

  • 0

I am creating a game in SVG and require square tiles to be placed along a path, named a road.

The path can be curved or placed in an angle and I would like to rotate the square tiles relative to the path.

My current structure looks like this:


<defs>
    <rect id="tile" width="200" height="200" stroke-width="5" stroke="red"/>
</defs>

<g style="stroke-width=10px; stroke:#23238E;>
   <path id="road1" d="M100 100 L 500 100"/>
   <path id="road2" d="M500 100 L 200 100"/>
</g>

My current understanding of SVG tells me I will have to calculate the positions of the tiles through interpolation but can I rotate the tiles relative to the path in an automated fashion?

So how can I apply <use x="xx" y="yy" orient="auto" xlink:href="tile"/> ?

The roads are generated from the following information:

id = #
vector2D = {
  x1 = #
  y1 = #
  x2 = #
  y2 = #
}
tiles = # // number of tiles in road
  • 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-11T14:37:28+00:00Added an answer on June 11, 2026 at 2:37 pm

    Raphael http://raphaeljs.com provides the angle of a path at any point through path.getPointAtLenght(x). SVG has a native implementation, but it doesn’t provide the angle. You could look into Raphael’s source to see what’s going on. Here is the relevant bit:

    getLengthFactory = function (istotal, subpath) {
            return function (path, length, onlystart) {
                path = path2curve(path);
                var x, y, p, l, sp = "", subpaths = {}, point,
                    len = 0;
                for (var i = 0, ii = path.length; i < ii; i++) {
                    p = path[i];
                    if (p[0] == "M") {
                        x = +p[1];
                        y = +p[2];
                    } else {
                        l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
                        if (len + l > length) {
                            if (subpath && !subpaths.start) {
                                point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
                                sp += ["C" + point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];
                                if (onlystart) {return sp;}
                                subpaths.start = sp;
                                sp = ["M" + point.x, point.y + "C" + point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]].join();
                                len += l;
                                x = +p[5];
                                y = +p[6];
                                continue;
                            }
                            if (!istotal && !subpath) {
                                point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
                                return {x: point.x, y: point.y, alpha: point.alpha};
                            }
                        }
                        len += l;
                        x = +p[5];
                        y = +p[6];
                    }
                    sp += p.shift() + p;
                }
                subpaths.end = sp;
                point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
                point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha});
                return point;
            }; 
    

    Where point.alpha is the rotation angle.

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

Sidebar

Related Questions

I'm creating a game where players can make an alloy. To make it less
I am creating a game for android and I would like the sprites to
I'm creating a game in python 2.7.2, but I've hit a snag. I would
Im creating flash game that have the functionality to capture/record its gameplay that can
I'm creating a game in C#. Each level is made up of several tiles.
I am creating a game in which a player can challenge a random player
I'm creating a game that I would like to consist of 2 scenes. One
Im creating a game an want to be able to add there score so
im creating a game that has multiple levels and the levels contain multiple textures
I am creating a game with winforms C#. The game contains some images that

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.