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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:23:21+00:00 2026-06-11T16:23:21+00:00

Possible Duplicate: Simple task (SVG vs. Canvas) I am trying to draw/paint a number

  • 0

Possible Duplicate:
Simple task (SVG vs. Canvas)

I am trying to draw/paint a number of circles and want to identify them with IDs on mouse over or mouse click.
I was trying to do this using KineticJS, not able to achieve as I am beginner at javascript.

Apart from that I just want to capture the normal mouse events (left/right click) and won’t be moving or playing with these circles apart from mouse events. So is the KineticJS is the right lib. to use ? How about Raphael JS/d3 etc. {By any chance can this is easily achieved by just Jquery/Dojo)
Only important thing is to draw large number of circles, ability to identify them uniquely and associate mouse events with them.

PS: Yes I Also want to accomplish the ability to zoom in/out the space/canvas in which these circles are drawn.

Please suggest. Thanks in Advance.

  • 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-11T16:23:22+00:00Added an answer on June 11, 2026 at 4:23 pm

    Try this below code, You can find the circle ID by mousemove on the circle

    <!DOCTYPE HTML>
    <html>
      <head>
        <style>
          body {
            margin: 0px;
            padding: 0px;
          }
          canvas {
            border: 1px solid #9C9898;
          }
        </style>
        <script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.0.1.js"></script>
        <script>
          window.onload = function() {
            var stage = new Kinetic.Stage({
              container: 'container',
              width: 578,
              height: 200
            });
            var circlesLayer = new Kinetic.Layer();
            var tooltipLayer = new Kinetic.Layer();
            var colors = ['red', 'orange', 'yellow', 'green', 'blue', 'cyan', 'purple'];
            var colorIndex = 0;
    
            var circleId ;
    
            for(var n = 0; n < 100; n++) {( function() {
                var i = n;
                var color = colors[colorIndex++];
                if(colorIndex >= colors.length) {
                  colorIndex = 0;
                }
                circleId = "CircleID_" + i;
                var randX = Math.random() * stage.getWidth();
                var randY = Math.random() * stage.getHeight();
                var circle = new Kinetic.Circle({
                  x: randX,
                  y: randY,
                  radius: 10,
                  fill: color,draggable:true,
                  id:circleId
                });
    
                circle.on('mousemove', function() {
                  // update tooltip
                  var mousePos = stage.getMousePosition();
                  tooltip.setPosition(mousePos.x + 5, mousePos.y + 5);
                  tooltip.setText('ID: ' + stage.get("#CircleID_" + i)[0].attrs.id);
                  tooltip.show();
                  tooltipLayer.draw();
                });
    
                circle.on('mouseout', function() {
                  tooltip.hide();
                  tooltipLayer.draw();
                });
    
                circlesLayer.add(circle);
              }());
            }
            var tooltip = new Kinetic.Text({
              text: '',
              fontFamily: 'Calibri',
              fontSize: 12,
              padding: 5,
              visible: false,
              fill: 'black',
              opacity: 0.75,
              textFill: 'white'
            });
    
            tooltipLayer.add(tooltip);
            stage.add(circlesLayer);
            stage.add(tooltipLayer);
          };
    
        </script>
      </head>
      <body>
        <div id="container"></div>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: byte[] array pattern search I am trying to write a simple compression
Possible Duplicate: C/C++ line number Hi, I have a simple error manager class that
Possible Duplicate: A comprehensive regex for phone number validation Just a simple regex required
Possible Duplicate: gwt and javascript files Seems like a simple enough task, but i'm
Possible Duplicate: Simple 2 way encryption for C# I want to encrypt data in
Possible Duplicate: simple regex in php, formatting decimal number How to convert a digit
Possible Duplicate: Simple and clean xml manipulation in PHP I trying to reference specific
Possible Duplicate: a simple function for return number from string in php What's the
Possible Duplicate: Can anyone recommend a simple Java web-app framework? I want to know
Possible Duplicates: windows service vs scheduled task Windows Service Vs Simple Program I'm trying

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.