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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:55:41+00:00 2026-05-27T10:55:41+00:00

Anyone has sample code for drawing a rubber band style path between two shapes

  • 0

Anyone has sample code for drawing a rubber band style path between two shapes in Raphael.

I saw few questions around drawing path progressively at How to draw a vector path progressively? (Raphael.js)

But my requirement is to be able to click on one shape and move the mouse to the other shape and while the mouse moves, there should be a line path following the mouse like a rubber band. Once the click happens on the second shape the line path has to be locked in.

I tried the Joint.js http://www.jointjs.com/ with Raphael but it can draw lines but not interactively.

  • 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-27T10:55:42+00:00Added an answer on May 27, 2026 at 10:55 am

    Here is the basic code to get you started:

    var w = window.innerWidth;
    var h = window.innerWidth;
    var paper = Raphael(0, 0, w, h);
    var nodes = paper.set();
    
    var circle1 = paper.circle(w/8, h/3, w/16)
        .attr({fill: "#000"})
        .click(line);
    var circle2 = paper.circle(w - w/8, h/3, w/16).attr({fill: "#000"})
        .attr({fill: "#000"})
        .click(line);
    
    
    function line() {
      var band = paper.path("M 0 0").attr({"stroke-width": 5})
      band.node.style.pointerEvents = "none";
      dimensions = this.getBBox();
      var x = dimensions.x + dimensions.width/2;
      var y = dimensions.y + dimensions.height/2;
      if (!window.onmousemove) {
        window.onmousemove = function(e){
            band.attr({path: "M " + x + " " + y + "L " + e.x + " " + e.y});
        }
      }
      else {
         window.onmousemove = null;
      }
    }
    

    You can check out a demo here: http://jsfiddle.net/57myn/

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

Sidebar

Related Questions

Anyone has sample code or know of a tutorial on how to do a
Does anyone has sample code for ordering in UITableView using NSOrderedSet? Had read many
Can anyone provide sample pseudocode or share some existing link that has sample code.
Has anyone tried the ActiveRecord Intro Sample with C# 3.5? I somehow have the
Does anyone has the code to a full working example of slartoolkit ( http://slartoolkit.codeplex.com/
Does anyone have some sample code or can direct me to which class I
I'm wondering if anyone has good resources to read or code to experiment for
Possible Duplicate: android steganography Has anyone implemented steganography on android? Can anyone post sample
anyone has a working example of a TTThumbsViewController used with files included in the
Anyone has a ready implementation of the Reverse Breadth First traversal algorithm in C#?

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.