Graphics Reference
In-Depth Information
<Canvas
xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x=
"http://schemas.microsoft.com/winfx/2006/xaml"
ClipToBounds= "True"
1
2
3
4
5
6
7
8
>
</Canvas>
The setting of ClipToBounds to True is almost always desired; it simply
ensures that the canvas is bounded, that is, it does not display any data outside
its assigned rectangular area.
We have not specified the size of the canvas, so its size will be controlled
by the application in which it appears. For example, the lab software for
Sections 2.4 and 2.5 (provided as part of the online materials) includes a “split-
screen” layout with the WPF canvas in one pane, vertically stacked on top of a
second pane displaying the XAML source code. The lab uses WPF layout man-
agers to allocate space between the two panes, and uses a draggable-separator
control to allow the user to exert some control over that allocation.
You will note that XAML has syntactic idiosyncrasies (such as the strange
xmlns properties in the Canvas tag shown above), but they rarely obscure the
semantics of the tags and properties, which are well named for the most part.
If you choose to investigate the more cryptic parts of the syntax, just use the
lab software: Click on any maroon-highlighted XAML code to request a brief
explanation.
2.4.2 Specifying the Scene via an Abstract
Coordinate System
Our sample application's scene—the simple clock—is a composite of several
objects: the face and three individual hands. The face object is a single ellipse
primitive filled with a solid-gray color. Two of the clock hands (minute and hour)
are navy-filled polygons, similar in shape but differing in size. Finally, there is the
red line forming the second hand.
Note that thus far in our simple scene graph, all the components are primitives,
but in a more complex scenario (introduced in Section 2.4.6), there may be a
hierarchy in which components may be composed of lower-level subcomponents.
With our list of components in hand, we now refine our specification by detail-
ing the precise geometry of each primitive.
Take a blank sheet of graph paper, choose and mark the (0,0) origin, and draw
the x -axis and y -axis—the result is the 2D Cartesian coordinate system. One of
its characteristics is that any two real numbers form an ( x , y ) coordinate pair that
uniquely identifies exactly one point on the plane.
But there's a limit to the lack of ambiguity of a graph-paper coordinate system.
People asked to draw a 4
4 square on graph paper will all produce a square shape
encompassing 16 grid squares, but these shapes will not have an identical areas in
terms of physical units (e.g., cm 2 ), because there is no single standard grid/ruling
size for graph paper.
Indeed, a sheet of graph paper is, by itself, an abstract coordinate system
in that it does not describe positions or sizes in the physical world. Using an
abstract system for geometry specification is perfectly fine—in fact, we are about
×
 
 
 
Search WWH ::




Custom Search