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

  • Home
  • SEARCH
  • 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 8891603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:47:16+00:00 2026-06-14T22:47:16+00:00

In plain svg , the <line> tag seems to do that just fine, e.g.

  • 0

In plain svg, the <line> tag seems to do that just fine, e.g.

<g>
    <line class="link" x1="180" y1="280" x2="560" y2="280"></line>
</g>
<g>
    <circle class="node" cx="180" cy="280" id="n1" r="18"></circle>
    <circle class="node" cx="560" cy="280" id="n2" r="18"></circle>
</g>

Here, the line element draws a line connecting the two defined nodes.

In RaphaelJS 2, is there a method for doing this? It seems like the most likely one is path, but when I try:

var paper = Raphael(document.getElementById("raphael-test"), 600, 600);
var c1 = paper.circle(180, 280, 18);
var c2 = paper.circle(560, 280, 18);
var edge = paper.path("M180,280L560,280");

the line extends into both circles, reaching the center of the circle. Visually I would like the line to just touch the line of circle. Of course, I can just work out the geometry and subtract the radius of the circle for each end given the pair coordinates. But I wonder if some method is already available from RaphaelJS 2, as this seems to be a very common functionality.

  • 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-14T22:47:17+00:00Added an answer on June 14, 2026 at 10:47 pm

    No. While it might seem like common functionality to you, this is actually a very bespoke usage for an SVG abstraction. If Raphael were to support something like this then you can imagine that feature requests would extend to things like drawing between arbitrary shapes without overlap.

    However, Raphael can help you with the computation as it is capable of computing path intersections. This works when you have a path string to represent your geometry.

    http://raphaeljs.com/reference.html#Raphael.pathIntersection

    See: http://jsfiddle.net/sDNMv/

    // Computes a path string for a circle
    Raphael.fn.circlePath = function(x , y, r) {      
      return "M" + x + "," + (y-r) + "A"+r+","+r+",0,1,1,"+(x - 0.1)+","+(y-r)+" z";
    } 
    
    // Computes a path string for a line
    Raphael.fn.linePath = function(x1, y1, x2, y2) {
        return "M" + x1 + "," + y1 + "L" + x2 + "," + y2;
    }
    
    var x1 = 180,
        y1 = 280,
        r1 = 18,
    
        x2 = 400,
        y2 = 280,
        r2 = 18,
    
        paper = Raphael(document.getElementById("raphael-test"), 600, 600),
        c1 = paper.circle(x1, y1, r1),
        c2 = paper.circle(x2, y2, r2),
    
        // Compute the path strings
        c1path = paper.circlePath(x1, y1, r1),
        c2path = paper.circlePath(x2, y2, r2),
        linePath = paper.linePath(x1, y1, x2, y2),
    
        // Get the path intersections
        // In this case we are guaranteed 1 intersection, but you could find any intersection of interest
        c1i = Raphael.pathIntersection(linePath, c1path)[0],
        c2i = Raphael.pathIntersection(linePath, c2path)[0],
    
    
        line = paper.path(paper.linePath(c1i.x, c1i.y, c2i.x, c2i.y));​
    

    You could also consider using getPointAtLength

    http://raphaeljs.com/reference.html#Raphael.getPointAtLength

    Since for circles, the points of intersection are the points on the line between them at length r and (distance between – r)

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

Sidebar

Related Questions

Plain text contains a custom tag that named <code>. Inside a tag there is
It is possible in plain Java to override a method of a class programmatically
I plan to have some (a lot of) objects inside of svg-object that will
In plain Java SE 6 environment: Logger l = Logger.getLogger(nameless); l.setLevel(Level.ALL); l.fine(somemessage); Nothing shows
in plain english can you please explain to me what does this line mean:
I have a plain text file that I need to read in using C#,
We are currently storing plain text passwords for a web app that we have.
When I send plain text emails using SmtpClient class, transfer encoding is set to
Plain old ASP, not .NET I've got a really large and complicated class for
Plain JS - please no jQuery suggestions - it is for a bookmarklet 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.