Java Reference
In-Depth Information
Transformations
Oneofthemostpowerfulfeaturesofvectorgraphicsisthepossibilityof
transforminganimagebymanipulatingitscoordinatepoints.Supposeyou
createarectangular-shapedpolygondefinedbythe x -and y -coordinatesof
itsfourscreenpoints.Ifyouaddaconstantvaluetoeachofthe x coordi-
natesofthisimage,theresultisarectangletranslatedalongthe x -axisby
theamountaddedtoeachcoordinatepoint.Bythesametoken,youcan
translateavectorimagetoanydesiredscreenlocationbyaddingorsub-
tractingaconstantvaluetoeachofits x and y coordinates.
Figure27-2 showsthetranslationofarectangularpolygonbyaddinga
constanttoitsxandycoordinates.
y
x=7,y=6
x=1,y=4
x
Figure27-2TranslationofaPolygon
In Figure27-2 therectangleinsolidlinesistranslatedtothepositionof
the rectangle in dashed lines by manipulating its coordinate points. In
this case a value of 6 was added to the x coordinate of each point and a
value of 2 to each of the y coordinates.
Other geometrical transformations that can be performed on vector
images are scaling and rotation. In scaling each coordinate point is multi-
plied by a scaling factor, which can be different for each coordinate
plane. In the rotation transformation the vector-based object is made to
move along a circular arc by applying a trigonometric function to each co-
ordinate point. Objects can be made to appear larger or smaller, can be
 
Search WWH ::




Custom Search