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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:34:01+00:00 2026-06-05T08:34:01+00:00

I have example for HTML 5 circle drawing as below https://i.stack.imgur.com/SVPO9.jpg Here is the

  • 0

I have example for HTML 5 circle drawing as below

https://i.stack.imgur.com/SVPO9.jpg

Here is the drawing script for this (HTML5 and jQuery)

http://jsfiddle.net/eGjak/275/

$.each(circles, function() {
   drawCircle(this);
   drawLine(mainCircle, this);
});

I need to upgrade this to drag and drop (the users can drag the children circles around the main circle with line)

How can I do this using html5,css3,jQuery?

  • 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-05T08:34:04+00:00Added an answer on June 5, 2026 at 8:34 am

    http://jsfiddle.net/eGjak/503/

    You have to find the local x and y on the canvas, then calculate the distance ( think pythagorean theorem, aSquared + bSquare = cSquared ), and see if the distance is less than the radius of the circle( aka mouse is within the circle )

    Add this code after the code you currently have

    var focused_circle, lastX, lastY ; 
    
    function test_distance( n, test_circle ){  //see if the mouse is clicking circles
        var dx = lastX - test_circle.x,
        dy = lastY - test_circle.y;
    
        //see if the distance between the click is less than radius
        if( dx * dx + dy * dy < test_circle.r * test_circle.r  ){
            focused_circle = n;
            $(document).bind( 'mousemove.move_circle' , drag_circle );
            $(document).bind( 'mouseup.move_circle' , clear_bindings);
            return false; // in jquery each, this is like break; stops checking future circles
        }
    }
    $('#cv').mousedown( function( e ){
        lastX = e.pageX - $(this).offset().left;
        lastY = e.pageY - $(this).offset().top;
        $.each( circles, test_distance );
    });
    
    function drag_circle( e ){
        var    newX = e.pageX - $('#cv').offset().left,
            newY = e.pageY - $('#cv').offset().top;
    
        //set new values
        circles[ focused_circle ].x += newX - lastX;
        circles[ focused_circle ].y += newY - lastY;
    
        //remember these for next time
        lastX = newX, lastY = newY;
    
        //clear canvas and redraw everything
        ctx.clearRect( 0, 0, ctx.canvas.width, ctx.canvas.height );
        drawCircle(mainCircle);
        $.each(circles, function() {
            drawCircle(this);
            drawLine(mainCircle, this);
        });
    
    }
    
    function clear_bindings( e ){ // mouse up event, clear the moving and mouseup bindings
        $(document).unbind( 'mousemove.move_circle mouseup.move_circle' );
        focused_circle=undefined;
    }
    

    There are other ways to do this and ways to save on speed, though this should do the trick.

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

Sidebar

Related Questions

Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
I'm new to cakephp and following this tutorial. http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html I have created the blog
I am using google chart and I have the following example: <html> <head> <script
For example, if I have example.com/experiments.html and the user types in example.com/experiment.html (no s),
So I have this string: (a url) example.html/#playYouTubeVideo=id[lBs8jPDPveg]&width[160]&height[90] I want to match id, width
I was reading the following article: http://java.sun.com/docs/hotspot/gc1.4.2/example.html and have trouble understanding the following lines:
I have html that looks like this, <div> <span>Text <a href=example.html>ABC</a> <a href=example.html>DEF</a> <a
I have following problem. I have a team page like this example: http://www.social-markets.de/social-commerce-team.html small
I have problem with adding class to every list element. This is example html:
I have template for example index.html.php where I use php assetic loader like this

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.