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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:26:11+00:00 2026-05-27T06:26:11+00:00

I have a Graphics2D object which I use to draw on my Canvas .

  • 0

I have a Graphics2D object which I use to draw on my Canvas. I draw multiple shapes on the Canvas and want to transform only one (or part) of them.

I’ll try to keep this simple:

void render(Graphics2D g) {
    ... // Draw shape 1
    ... // Draw shape 2
    ... // Draw shape 3
}

How would I go about rotating shape 2 while leaving shape 1 and 3 intact? By “rotate” I mean rotating around its center point, which we can define as x and y for example.

I’ve been looking for a way to do this for a while now, but couldn’t find anything that works the way I want it to.

Is there any simple way to do this?

  • 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-27T06:26:12+00:00Added an answer on May 27, 2026 at 6:26 am

    Rather than rotating the shape around it’s centre point, rotate and then translate the canvas. To rotate around the centre of the shape at (x, y), first translate the canvas by (-x, -y) and then rotate the canvas -d degrees and draw the shape as normal at (0,0).

    When you’re done, rotate back then translate back (note that with these geometric transformations the order is important, translating and then rotating will give you a completely different outcome).

    This means that you can still draw an object at any rotation without having to recalculate the coordinates yourself.

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

Sidebar

Related Questions

Here's the situation: We have some generic graphics code that we use for one
In my program I want to draw a simple score line graph. I have
I am creating a game in which I have a menu with multiple views
I have a list of strings which I paint on an axis. I want
I have a Graphics object of JPanel and that is working fine: import java.awt.Color;
I have a form that tries to modify a JComponent's graphics context. I use,
I have a function that draw an image on graphics: private void DrawSmallImage(Graphics g)
I'm trying to use the Sprite Class in Microsoft.DirectX.Direct3D to draw some sprites to
I have a JSF 2 application which creates some SVG content. How can i
I have recently begin creating an image editing tool which will cater to a

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.