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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:37:06+00:00 2026-05-27T05:37:06+00:00

Why is the following code not rendering the image at an angle. (I want

  • 0

Why is the following code not rendering the image at an angle.
(I want the image to be rendered on an anchored point on the image). I think that it is rotating around the screen. How can I fix this?

public void drawWeapon(Graphics2D g) {
    int iconSize = main.SOutput.iconSize;
    int ePosX =(int) (getPosX() * iconSize 
                - (int) main.player.getPosX() *iconSize)/iconSize;
    int ePosY =(int) (getPosY() * iconSize 
                - (int) main.player.getPosY() *iconSize)/iconSize;

    int PosX = ePosX + (main.SOutput.resX/2)*iconSize 
                + main.SOutput.xPaddingSide;
    int PosY = ePosY + (main.SOutput.resY/2)*iconSize 
                - getImageSizeY()*iconSize;

    if (inventory[0][main.gui.itemSelected] != null){
    g.rotate(facingLeft?scincePressed:-scincePressed);
    g.drawImage(inventory[0][main.gui.itemSelected].item.getImage(), 
                 PosX + (facingLeft?0:getImageSizeX() * iconSize/2), PosY +
                 (getImageSizeY() * iconSize/2), getImageSizeX() * iconSize/2,
                 getImageSizeY() * iconSize/3, null);
    g.rotate(facingLeft?-scincePressed:scincePressed);
    }
}
  • 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-27T05:37:06+00:00Added an answer on May 27, 2026 at 5:37 am

    You should use this way of working:

    1. Push the matrix
    2. Translate to the point of rotation
    3. Rotate
    4. Render at (0, 0)
    5. Pop matrix

    In code, it would be:

    AffineTransform matrix = g.getTransform();
    g.translate(originX, originY);
    g.rotate(angle);
    g.drawImage(0, 0, ...);
    g.setTransform(matrix);
    

    You might also try Graphics2D.rotate(theta, originX, originY);

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

Sidebar

Related Questions

I have the following code that I want to achieve the following with. Check
Why does the following code not work as I was expecting? <?php $data =
Why does the following code NOT give an error, nor any type of a
Why is the following code not working? if(EventLog.Exists(Foo)) { EventLog.Delete(Foo); } if(EventLog.Exists(Foo) == false)
The following class is not thread-safe (as proven in Proving the following code not
can anybody tell me why is the following code not working? <script type=text/javascript src=../../Scripts/jquery.js></script>
I have a transparent BufferedImage created with the following code(not relevant how it is
i am using python 2.5.2 . The following code not working. def findValue(self, text,
The following code does not compile: public class GenericsTest { public static void main(String[]
The following Code does not compile Dim BasicGroups As String() = New String() {Node1,

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.