The Graphics class represents a GDI+ drawing surface. A Graphics object maintains the state of the drawing surface, including the scale and units, as well as its orientation. The Graphics class provides a great many properties. The most commonly used ones are listed in Table 5-2.
The PageScale sets the scaling between the world units and the page units. To understand these, you must first understand coordinates. 5.1.1.5.1.1.1. CoordinatesThe French philosopher Rene Descartes (1596-1650) is best known today for stating that while he may doubt, he cannot doubt that he exists. This is summarized in his oft-quoted statement Cogito Ergo Sum ("I think; therefore, I am"). Among mathematicians, however, Descartes is known for inventing Analytical Geometry and what are now called Cartesian coordinates . In a classic Cartesian coordinate system, you envision an x-axis and a y-axis, as shown in Figure 5-2, with the origin (0,0) at the center. The values to the right of the origin and above the origin are positive, and the values to the left and below the origin are negative. The coordinates you pass to the various drawing methods of the Graphics class are said to be World Coordinates . Unlike traditional Cartesian coordinates, World Coordinates have their origin at the upper lefthand corner, rather than in the center, and you count upward to the right and down, as shown in Figure 5-3. 5.1.1.2. Transforms introducedThese World Coordinates are transformed into page coordinates by world transformations. You'll use these world transformations (e.g., translateTransform, ScaleTransform, and RotateTransform) to set the center and the orientation of your coordinate system. When drawing a clock face, for example, it will be more convenient to set the origin (0,0) to the center of the clock. Page transforms convert page coordinates into device coordinates: that is, pixels relative to the upper lefthand corner of the client area on your monitor. The page transforms are the PageUnit and PageScale properties of the Graphics object. The PageUnit property chooses the unit you'll use to make your transformations and to scale your drawings. These units are one of the GraphicsUnit enumerated values shown in Table 5-3. Figure 5-2. Cartesian coordinatesFigure 5-3. World Coordinates
Using the unit described by the PageUnit you can set the PageScale, which specifies the value for scaling between world units and page units. You'll see this at work later in this chapter when you'll create a scale of 2,000 units by 2,000 units that is, rather than working in pixels or inches, you'll create a logical unit that is 1/2,000 of the width (or height) of your screen. |