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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:30:38+00:00 2026-05-22T18:30:38+00:00

I have a Raphaël text object that I would like to rotate around an

  • 0

I have a Raphaël text object that I would like to rotate around an axis some distance away and also rotate the text accordingly so it stays horizontal. I know this is possible using SVG transformation matrices, but the author of Raphaël has stated that they won’t be a part of the toolkit anytime soon. Here’s some code of what I’d like to do:

txt_obj = paper.text(100, 100, "Hello!");
txt_obj.rotate(90, 100, 200); // rotate text so it is sideways at (200,200)
txt_obj.rotate(-90); // rotate text back to horizontal

Unfortunately, the second rotate command obliterates the translation and rotation accomplished by the first.

If I were doing straight SVG I could do something like this:

<g transform="rotate(90, 100, 200)">
    <text x="100" y="100" transform="rotate(-90, 100, 100)">Hello!</text>
</g>

However, I don’t believe that Raphaël supports the svg g element.

Ideally I’d like to animate the operation, but I’ll take it one step at a time for right now.

  • 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-22T18:30:38+00:00Added an answer on May 22, 2026 at 6:30 pm

    This is an old question but I just fought my way through it so I thought I’d share my answer.

    You can access the SVG object directly, even inside your Raphael calls, thusly:

    this.node.getAttribute('x')
    

    or

    this.node.getAttribute('transform')
    

    The second one is what gets us what we need. The trouble with rotating text with Raphael is all it does is set the transform in the SVG:

    <text x="600" y="606.240234375" text-anchor="middle" style="text-anchor: middle; 
    font: normal normal normal 10px/normal Arial; font-family: Arial; font-weight: 900;
    font-size: 18px; " font="10px &quot;Arial&quot;" stroke="none" fill="#000000" 
    font-family="Arial" font-weight="900" font-size="18px" transform="rotate(45 600 600)">
    <tspan style="-webkit-user-select: none; cursor: pointer; ">FOOBAR</tspan></text>
    

    Multiple calls to .rotate() overwrite previous settings so finally there’s only one call to rotate in the SVG transform. But we can add our own transforms by accessing the attribute directly. Transforms seem to be performed in reverse order (or something — I honestly haven’t thought about it too hard) so you put your additional rotation last if you want it to go first:

    <script>
    (function (raphael) {
      $(function () {
        var paper = raphael("raphael_div", 500, 500);
    
        upside_down_text = paper.text(100,100,'UPSIDE DOWN')
                                .attr('font-family','Arial')
                                .attr('font-size','24px');                           
        upside_down_text.rotate(25,250,250); // rotate using Raphael
        // But first we want to rotate 180 degrees.
        height = upside_down_text.getBBox().height;
        upside_down_text.node.setAttribute('transform',
                                           upside_down_text.node.getAttribute('transform')+
                                           ' rotate(180 '+
                                           upside_down_text.node.getAttribute('x')+
                                           ' '+
                                           (upside_down_text.node.getAttribute('y')-(height/2))+
                                           ')');
      });
    })(Raphael.ninja());
    </script>
    <div id="raphael_div"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text file with some stuff that i would like to put into
I have a gridview that i would like to show or hide a text
I have a TextBox that is bound to a Text-property on an Entity-object. I'd
I have a Stringbuilder object that has been populated from a text file. How
I have an object that processes text in a stateless way. It basically takes
I have a Collection of items that I would like to display the Total
I am creating some text boxes at runtime and I would like to change
I have a model that I would like to serialize to an xml with
I have an xml file that looks something like this <questions> <question> <text>What color
I would like to use create a object that contains regular expressions as the

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.