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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:47:57+00:00 2026-05-17T23:47:57+00:00

If someone has the answer could you help me, please? I have 2 images

  • 0

If someone has the answer could you help me, please?
I have 2 images – background similar to arc and arrow. And i need to move arrow image over background image like this is a clock ticker arrow. So i need :

  1. Rotate arrow to make it parallel to current tick on the arc
  2. Move arrow to the next point

For this i need to use Canvas object in JavaScript and its method transform – this will allow to move arrow and rotate it.

The question is : how to use canvas.transform method to rotate (and desirable move) arrow around the arc? And which values and what relation between them should be in this case :

contextData.clearRect (0, 0, contextData.canvas.width, contextData.canvas.height);
contextData.save ();
contextData.translate(indicatorData.width () / 2, indicatorData.height () / 2);
contextData.transform(1, 0, 0, 1, x, y);  // the question is HERE
contextData.drawImage(rotationArrow, -rotationArrow.width / 2, -rotationArrow.height / 2);
contextData.restore ();

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-05-17T23:47:57+00:00Added an answer on May 17, 2026 at 11:47 pm

    Almost forgot … i found the answer, it works and this is the final code. To make it worked in IE you should add excanvas library from Google and to fix some IE8 issues you need to add compatibility meta tag :

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
       <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
       <title>Canvas</title>
       <script type="text/javascript" src="jquery.min.js"></script>
       <script type="text/javascript" src="excanvas.js"></script>
    </head>
    <body>
    
    <div class="indicator">
       <img class="image" src="usage_icon_electro.png" alt="" />
       <img class="pointer" src="usage_electro_pointer.png" alt="" />
       <canvas width="120" height="120" id="canvas"></canvas>
    </div>
    
    <script type="text/javascript">
    
    var indicatorClass = {
    
       timerHandle : 0,
       timerDelay : 10,
    
       rotationIncrement : 1,
       rotationStep : 0,
       rotationSteps : 50,
       rotationRadius : 35,
    
       angleCurrent : 5,
       angleDelta : 150,
    
       directionClockwise : true,
    
       canvasIndicator : null,
       canvasPointer : null,
       canvasContext : null,
    
       getRadianAngle : function (degreeValue) {
          return degreeValue * Math.PI / 180;
       },
    
       initCanvas : function (optionList) {
    
          try {
    
             var canvasData = $ ('.indicator #canvas').get (0);
    
             if ($.browser.msie) {
                canvasData = document.createElement('canvas');
                $ (canvasData)
                   .attr ('width', 120)
                   .attr ('height', 120)
                   .attr ('id', 'canvas')
                   .appendTo('.indicator');
                canvasData = G_vmlCanvasManager.initElement(canvasData);
                /*
                var metaCompatible = document.createElement('meta');
                $ (metaCompatible)
                   .attr ('http-equiv', 'X-UA-Compatible')
                   .attr ('content', 'IE=EmulateIE7')
                   .prependTo('head');
                */
                //$ ('head').prepend ('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />');
    //alert ($ ('head').html ());
             }
    
             indicatorClass.canvasIndicator = $ ('.indicator');
             indicatorClass.canvasPointer = $ ('.indicator .pointer').get (0);
             indicatorClass.canvasContext = canvasData.getContext ("2d");
    
             $.extend (indicatorClass, optionList);
    
             var angleMax = indicatorClass.angleCurrent + indicatorClass.angleDelta;
             indicatorClass.setRotationAngle (510);
    
             indicatorClass.timerHandle = setInterval(function () { 
                if (indicatorClass.angleCurrent > angleMax) {
                   clearInterval (indicatorClass.timerHandle);
                }
                indicatorClass.angleCurrent += indicatorClass.rotationIncrement;
                indicatorClass.rotationStep += indicatorClass.rotationIncrement;
                indicatorClass.setRotation (); 
             }, indicatorClass.timerDelay);
    
          } catch (exceptionData) {
             alert ('Indicator is not loaded');
          }
       },
    
       getCircleCoords : function (stepIndex) {
    
          var centerX = indicatorClass.canvasIndicator.width () / 2;
          var centerY = indicatorClass.canvasIndicator.height () / 2;
          var coordValues = {
             currentX : (centerX + indicatorClass.rotationRadius * Math.cos (2 * Math.PI * stepIndex / indicatorClass.rotationSteps)),
             currentY : (centerY + indicatorClass.rotationRadius * Math.sin (2 * Math.PI * stepIndex / indicatorClass.rotationSteps))
          }
    
          return coordValues;
       },
    
       setRotationAngle : function (angleValue) {
    
          indicatorClass.canvasContext.translate(indicatorClass.canvasIndicator.width () / 2, indicatorClass.canvasIndicator.height () / 2);
    
          for (var currentAngle = 90; currentAngle <= 720; currentAngle++) {
    
             var sin = Math.sin(currentAngle * Math.PI / 360);  
             var cos = Math.cos(currentAngle * Math.PI / 360);
             var deltaX = indicatorClass.directionClockwise ? -sin : sin;
             var deltaY = indicatorClass.directionClockwise ? sin : -sin;
    
             if (currentAngle > angleValue) {
                indicatorClass.canvasContext.transform(cos, deltaY, deltaX, cos, 0, 0);
                return false;
             }
          }
       },
    
       setTransform : function () {
    
          var sin = Math.sin(indicatorClass.rotationStep * Math.PI / indicatorClass.rotationSteps);  
          var cos = Math.cos(indicatorClass.rotationStep * Math.PI / indicatorClass.rotationSteps);
          var deltaX = indicatorClass.directionClockwise ? -sin : sin;
          var deltaY = indicatorClass.directionClockwise ? sin : -sin;
    
          //indicatorClass.canvasContext.clearRect (0, 0, indicatorClass.canvasContext.canvas.width, indicatorClass.canvasContext.canvas.height);
          indicatorClass.canvasContext.save ();
          //indicatorClass.canvasContext.translate(indicatorClass.canvasIndicator.width () / 2, indicatorClass.canvasIndicator.height () / 2);
          indicatorClass.canvasContext.transform(cos, deltaY, deltaX, cos, 0, 0);
          indicatorClass.canvasContext.clearRect (-screen.width, -screen.height, screen.width, screen.height);
          indicatorClass.canvasContext.drawImage(indicatorClass.canvasPointer, -indicatorClass.canvasPointer.width / 2, -indicatorClass.canvasPointer.height - indicatorClass.rotationRadius);
          indicatorClass.canvasContext.restore ();
       },
    
       setRotation : function () {
    
          var currentAngle = indicatorClass.directionClockwise ? indicatorClass.angleCurrent : -indicatorClass.angleCurrent;
    
          indicatorClass.canvasContext.save ();
          indicatorClass.canvasContext.rotate(indicatorClass.getRadianAngle (currentAngle));
          indicatorClass.canvasContext.clearRect (-screen.width, -screen.height, screen.width, screen.height);
          indicatorClass.canvasContext.drawImage(indicatorClass.canvasPointer, -indicatorClass.canvasPointer.width / 2, -indicatorClass.canvasPointer.height - indicatorClass.rotationRadius);
          indicatorClass.canvasContext.restore ();
       }
    
    }
    
    window.onload = function () {
       indicatorClass.initCanvas ();
    }
    
    </script>
    
    <style type="text/css">
    .indicator {
       width:120px;
       height:120px;
       border:1px solid #ccc;
       text-align:center;
       position:relative;
    }
    .indicator .pointer {
       visibility:hidden;
    }
    .indicator #canvas {
       z-index:10000;
       position:absolute;
       top:0;
       left:0;
       width:100%;
       height:100%;
    }
    </style>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope someone has an easy answer on this. I have a header image which
Someone has an answer to this missing feature in Entity Framework. Does anyone have
I have a very weird problem.. I really do hope someone has an answer
This StackOverflow answer has an image of KDiff3 highlighting intra-line differences. Does someone know
Someone has asked the exact same question in April, without any answer. But since
I am sure someone has this done already, and was hoping someone could share
I'm sure someone can explain this. we have an application that has been in
The closest answer I could find to my question here was this (which has
I'm trying to filter through some images. Each image has 3 sets of values
Would someone please provide me an example of the following Activity/Service/Application combination. I have

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.