Graphics Reference
In-Depth Information
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<Canvas.RenderTransform>
...same as before...
</Canvas.RenderTransform>
<Canvas.Triggers>
<EventTrigger RoutedEvent= "FrameworkElement.Loaded" >
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName= "ActualTimeHour"
Storyboard.TargetProperty= "Angle"
From= "0.0" To= "360.0"
Duration= "00:00:01:0" RepeatBehavior= "Forever"
/>
<DoubleAnimation
Storyboard.TargetName= "ActualTimeMinute"
Storyboard.TargetProperty= "Angle"
From= "0.0" To= "4320.0"
Duration= "00:00:01:0" RepeatBehavior= "Forever"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Canvas.Triggers>
</Canvas>
As a starting point in transforming this scene description into an image, we'll
assume that we have a basic graphics library that, given an array of points rep-
resenting a polygon, can draw that polygon. The points will be represented by a
3
k array of homogeneous coordinate triples, so the first column of the array will
be the homogeneous coordinates of the first polygon point, etc.
We'll now explain how we can go from something like the WPF description to
a sequence of drawPolygon calls. First, let's transform the XAML code into a tree
structure, as shown in Figure 10.18, representing the scene graph (see Chapter 6).
We've drawn transformations as diamonds, geometry as blue boxes, and
named parts as beige boxes. For the moment, we've omitted the matter of instanc-
ing of the ClockHandTemplate and pretended that we have two separate identical
copies of the geometry for a clock hand. We've also drawn next to each transfor-
mation the matrix representation of the transformation. We've assumed that the
angle in ActualTimeHour is 15 (whose cosine and sine are approximately 0.96
and 0.26, respectively) and the angle in ActualTimeMinutes is 180 (i.e., the clock
is showing 12:30).
×
Inline Exercise 10.19: (a) Remembering that rotations in WPF are specified
in degrees and that they rotate objects in a clockwise direction, check that the
matrix given for the rotation of the hour hand by 15 is correct.
(b) If you found that the matrix was wrong, recall that in WPF x increases to the
right and y increases down. Does this change your answer? By the way, if you
ran this program in WPF and debugged it and printed the matrix, you'd find
the negative sign on the ( 2, 1 ) entry instead of the ( 1, 2 ) entry. That's because
WPF internally uses row vectors to represents points, and multiplies them by
transformation matrices on the right.
 
Search WWH ::




Custom Search