tom1234
asked on
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??
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??
ASKER
hm...
I can not understand..
please , tell me more detaily?
I can not understand..
please , tell me more detaily?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER
can you tell me the meaning of 'translate method'?
shifts points a fixed number of pixels in x and y direction
without the translations it would rotate arounf the top left corner of image