[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

why using translate twice?

 GC gc = e.gc;
  gc.setAdvanced(true);
 
  Bounds b = image.getBounds();

  Transform transform = new Transform(display);
  // The rotation point is the center of the image
  transform.translate(50 + b.width/2, 50 + b.height/2);
  // Rotate
  transform.rotate(45);
  // Back to the orginal coordinate system
  transform.translate(-50 - b.width/2, -50 - b.height/2);
  gc.setTransform(transform);
  gc.drawImage(image, 50, 50);
  transform.dispose();

above the code, a translate method is used twice . why is it used twice??
0
gamjaradio
Asked:
gamjaradio
  • 3
  • 3
1 Solution
 
objectsCommented:
so that it is rotated on the centre of the image
without the translations it would rotate arounf the top left corner of image
0
 
gamjaradioAuthor Commented:
hm...
I can not understand..

please , tell me more detaily?
0
 
objectsCommented:
1. translates to the centre of image
2. rotate image
3. translate back to top left corner

try it without the translates to see the difference
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
gamjaradioAuthor Commented:
thanks
0
 
gamjaradioAuthor Commented:
can you tell me the meaning of 'translate method'?
0
 
objectsCommented:
shifts points a fixed number of pixels in x and y direction
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now