10.7. Coordinate Transformations

Java 2D allows you to easily translate, rotate, scale, or shear the coordinate system. This capability is very convenient: moving the coordinate system is often much easier than calculating new coordinates for each of your points. Besides, for some data structures like ellipses and strings, the only way to create a rotated or stretched version is through a transformation. The meanings of translate, rotate, and scale are clear: to move, to spin, or to stretch/shrink evenly in the x and/or y direction. Shear means to stretch unevenly: an x shear moves points to the right, based on how far they are from the y-axis; a y shear moves points down, based on how far they are from the x-axis.

The easiest way to picture ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.