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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:37:03+00:00 2026-05-20T01:37:03+00:00

I have an image that I draw on a canvas. When the mouse clicks

  • 0

I have an image that I draw on a canvas. When the mouse clicks and drags, I get the mouse coordinates and use them to set the position X and Y of the image. After that’s been done, I redraw the canvas. That works like a charm and I can move the image over the canvas.

But now I make 2 buttons, so I can rotate the image left and right. When I rotate the image, it now moves relative to the angle I have rotated. So when I rotate the image 180 degrees and drag the image up, it goes down! I don’t know why this happens or how I can compensate for it. 🙁

Well, I understand I may be a bit vague so here is a demo of the problem.

  • 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-20T01:37:03+00:00Added an answer on May 20, 2026 at 1:37 am

    I cannot access the demo url you provided, but this should be universal.

    You need to move your object to the base of your coordinate space o:(0,0), do your rotation, and then move your object back to where it was before you moved it, and since all your transformations are joined into a single transformation matrix, the order of transformations is very important, and you basically just need to do them inversely, i.e. move your object back to its initial position, then rotate it, and then move it to the coordinate space base:

    ctx.translate(objects_x_position, objects_y_position);
    ctx.rotate(angle);
    ctx.translate(-objects_x_position, -objects_y_position);
    

    And voila.
    Here’s the demo: http://jsfiddle.net/ArtBIT/CdbWx/1

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

Sidebar

Related Questions

I have a function that draw an image on graphics: private void DrawSmallImage(Graphics g)
I have an image that I get and attempt to load into a graphics
I have image data and i want to get a sub image of that
I have a static image (a png) that I'm drawing on a canvas element
I have a Canvas that i draw text on. (this is quite advanced i
so having a canvas and canvasContext I want to draw an image onto that
I have a script that draws an image on a canvas and allows people
I have two images that i want to draw into a canvas object. I
i have an image that contains a series of images, e.g.: In the olden
I have an image that I'm rendering like this: glDrawPixels(image->width, image->height, GL_BGR, GL_UNSIGNED_BYTE, image->imageData);

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.