Graphics Reference
In-Depth Information
Application coordinate system
Circle of 20 3 20 units, centered at origin
x
The visible quadrant
of a WPF canvas
Figure 2.10: Schematic view of our application's initial specification of the clock-face
ellipse.
lives in the application with no physical representation, and the red arrow repre-
senting the rendering process that produces the displayed image.
Here, we are seeing the effect of delivering abstract coordinates directly to the
graphics platform. It is OK to use abstract coordinates to design your scene, but
when it's time to worry about how it will appear on the display, we must consider
(1) characteristics of the display device, such as size, resolution, and aspect ratio;
(2) how we want the rendered image to be sized and positioned in consideration of
the form factor's constraints; and (3) how to specify the geometry to the graphics
platform in order to achieve the desired result.
In Section 2.6, we will discuss these considerations in the scope of full-featured
applications. Here, for our simple clock application, let's assume that the canvas
will be displayed on a laptop screen, that the clock should be an “icon-sized” 1
inch in diameter, and that the clock should appear in the upper-left corner of the
canvas. How can we revise our application to achieve this desired appearance?
2.4.3 The Spectrum of Coordinate-System Choices
We now have a specific physical size (one inch in diameter) in mind for our clock
scene. So, should we reconsider our decision to design the geometry using an
abstract coordinate system? To answer this question, let's consider two alternative
coordinate systems we might choose for scene description.
We could consider using an integer-pixel-based coordinate system like that
described in Section 2.3.1, but that is not appropriate given our need to control the
displayed size of our scene, independent of screen resolution.
Alternatively, we can consider designing our scene using the WPF canvas
coordinate system, which is “physical”—the unit of measurement is 1
96 of an
inch—and not resolution dependent. For example, an application can draw a rect-
angle of size 1
/
4 inches by specifying a width of 12 units and a height of
24 units. 3 Thus, we can create a circle that is 1 inch in diameter by specifying the
diameter as 96 units.
Although direct use of the WPF coordinate system does provide resolution
independence, we do not recommend that strategy, for there are two other kinds
of independence worthy of pursuit.
Software-platform independence: By using the coordinate system of a
specific graphics platform, we are unnecessarily tying portions of our appli-
cation code to that platform, potentially increasing the work that would be
necessary to later “port” the application to other platforms.
/
8
×
1
/
3. There are limitations to physical coordinate systems. Perfect accuracy in the sizes of
displayed shapes cannot be guaranteed due to dependencies on disparate parts, includ-
ing the device driver and the screen hardware.
 
 
Search WWH ::




Custom Search