Transformation is not a good understanding of the concept, not to scare you, it involves a lot of knowledge about algebra, geometry, and linear algebra. How? Scared by my words? Don't be afraid, although we may not be able to understand these concepts as long as we know how to use them.
In fact, the transformation is a coordinate change on the plane, sounds very abstract, but, as long as I say it specifically, you will feel not abstract.
I believe that if you play Photoshop, or other drawing software, you should know what is called rotation, what is called tilt, what is called panning ...
Yes, these are the changes we're going to talk about today, okay, now can you sit down and have a glass of pearl milk tea to relax? Oh, yes, pearl milk tea as much as possible to drink oh.
Well, gossip less and start today's show.
First, TranslateTransform.
This should be regarded as the best understanding, is the translation, I believe we will not be unfamiliar, learning analytic geometry when is not often play ah? It is nothing more than two parameters--x and Y, respectively, is the displacement of the plane on the two direction.
The three rectangles in the, their positions are the same, but after panning, it looks as if they are not in the same position.
- <Canvas>
- <!--three rectangles are in the same position in the canvas, but after panning the transform,
- It looks as if it's not in the same position.
- -
- <rectangle width= "height=" 120 "
- Fill= "Darkgreen"
- canvas.zindex= "0"
- canvas.top= "15"
- Canvas.left= ">"
- <Rectangle.RenderTransform>
- <translatetransform x= "y="/>
- </Rectangle.RenderTransform>
- </Rectangle>
- <rectangle width= "height=" 120 "
- Fill= "Yellow"
- canvas.zindex= "1"
- canvas.top= "15"
- Canvas.left= ">"
- <Rectangle.RenderTransform>
- <translatetransform x= "y="/>
- </Rectangle.RenderTransform>
- </Rectangle>
- <rectangle width= "height=" 120 "
- Fill= "Blue"
- canvas.zindex= "2"
- canvas.top= "15"
- Canvas.left= ">"
- <Rectangle.RenderTransform>
- <translatetransform x= "y="/>
- </Rectangle.RenderTransform>
- </Rectangle>
- </Canvas>
Second, RotateTransform.
This guy is used to rotate the element, the angle attribute is the angle of rotation, without my explanation, the knowledge of the pupils. In addition, there are two attributes to note:
CenterX: The x-coordinate of the center of rotation, which is relative to the upper-left corner of the target, for example, if you want a rectangle to rotate, by default, the center of rotation is 0, which is the upper-left corner of the rectangle;
CenterY: The same as above, just the y-coordinate point.
These two rotation points are not very good to grasp, if we want to compare relative positioning, you can change the rotation origin by UIElement's Rendertransformorigin property, this point coordinate is relative to the element visualization boundary, namely 0 to 1 values, such as:
1. Upper left Corner: (0,0)
2. Lower left corner: (+)
3, the top of the Center: (0.5,0)
4, Bottom Center: (0.5,1)
In the three images, the center of rotation is centered at the bottom, but the angle of rotation is different.
- <Grid>
- <image margin= "289,42,241,143" source= "/transformsample;component/1.jpg" stretch= "Uniform" Opacity= "0.3"
- rendertransformorigin= "0.5,1" >
- <Image.RenderTransform>
- <rotatetransform angle= " -60"/>
- </Image.RenderTransform>
- </Image>
- <image margin= "289,42,241,143" source= "/transformsample;component/1.jpg" stretch= "Uniform" Opacity= "0.6"
- rendertransformorigin= "0.5,1" >
- <Image.RenderTransform>
- <rotatetransform angle= "0"/>
- </Image.RenderTransform>
- </Image>
- <image margin= "289,42,241,143" source= "/transformsample;component/1.jpg" stretch= "Uniform"
- rendertransformorigin= "0.5,1" >
- <Image.RenderTransform>
- <rotatetransform angle= "/>"
- </Image.RenderTransform>
- </Image>
- </Grid>
Third, ScaleTransform.
Similar to the rotation transformation above, but this is for zooming in and out, it also has a center point, which is the zoom center, again, its default value is the upper left corner of the target element, as to which point is the Zoom Center, you adjust the center coordinates.
In order to clearly see the effect of zooming, the following two images are set to transparency.
- <Grid>
- <image source= "/transformsample;component/1.jpg" stretch= "Uniform" horizontalalignment= "Center" Verticalalignment= "Center" margin= "130"
- canvas.zindex= "0" opacity= "0.09" >
- <Image.RenderTransform>
- <scaletransform centerx= "centery=" scalex= "2" scaley= "2"/>
- </Image.RenderTransform>
- </Image>
- <image source= "/transformsample;component/1.jpg" stretch= "Uniform" horizontalalignment= "Center" Verticalalignment= "Center" margin= "130"
- canvas.zindex= "1" opacity= "0.2" >
- <Image.RenderTransform>
- <scaletransform centerx= "centery=" scalex= "1.6" scaley= "1.6"/>
- </Image.RenderTransform>
- </Image>
- <image source= "/transformsample;component/1.jpg" stretch= "Uniform" horizontalalignment= "Center" Verticalalignment= "Center" margin= "130"
- canvas.zindex= "2"/>
- </Grid>
Four, SkewTransform.
The twisted transformation, which can be said to be tilted, does achieve the effect of tilting.
It also has a central point, similar to the above, where the Anglex is distorted along the x axis, and the Angley is twisted along the y axis.
- <Grid>
- <image source= "/transformsample;component/1.jpg" horizontalalignment= "Center"
- Verticalalignment= "Center"
- Margin= "/>"
- <image source= "/transformsample;component/1.jpg" horizontalalignment= "Center"
- Verticalalignment= "Center"
- margin= "opacity=" "0.3" >
- <Image.RenderTransform>
- <skewtransform centerx= "0" centery= " -200" anglex= "" angley= "0"/>
- </Image.RenderTransform>
- </Image>
- <image source= "/transformsample;component/1.jpg" horizontalalignment= "Center"
- Verticalalignment= "Center"
- margin= "opacity=" "0.3" >
- <Image.RenderTransform>
- <skewtransform centerx= "0" centery= " -550" anglex= " -15" angley= "0"/>
- </Image.RenderTransform>
- </Image>
- </Grid>
Five, TransformGroup.
Strictly speaking, this is not a transformation, but it can be achieved by adding n transformations together.
- <Grid>
- <image source= "/transformsample;component/1.jpg"
- Stretch= "Uniform" margin= "65,98,472,92"/>
- <image source= "/transformsample;component/1.jpg"
- Stretch= "Uniform" margin= "65,98,472,92" >
- <Image.RenderTransform>
- <TransformGroup>
- <translatetransform x= "y="/>
- <scaletransform scalex= "1.5" scaley= "1.5" centerx= "185" centery= "280"/>
- <rotatetransform centerx= "centery=" angle= "/>"
- </TransformGroup>
- </Image.RenderTransform>
- </Image>
- </Grid>
Six, Compositetransform.
This is a bit like the transformgroup above, but as you can see, it does not overlay multiple transformations, but applies multiple transformations at the same time, but it is sequential.
Shift---rotation----Warp, zoom
- <Grid>
- <image source= "/transformsample;component/1.jpg" stretch= "Uniform" margin= "48,68,492,131"/>
- <image source= "/transformsample;component/1.jpg" stretch= "Uniform" margin= "48,68,492,131"
- opacity= "0.5" >
- <Image.RenderTransform>
- <compositetransform
- centerx= "" centery= "185"
- Rotation= "45"
- skewx= "skewy=" 15 "
- scalex= "1.2" scaley= "1.2"
- translatex= "translatey=" "/>"
- </Image.RenderTransform>
- </Image>
- </Grid>
Seven, Matrixtrasform.
This is the most complex of a transformation, it is a 3-by-3 matrix, but because it 3rd column 0,0,1, so, in fact, we only need to set 6 values is enough. Each of them is:
M11 M12 0
M21 M22 0
OffsetX OffsetY 1
May be offsetx and offsety more easy to see is the displacement, that front? We can guess that the default value of 1 is scaling, because it is not possible to be 0 times times, the remaining two is the x-axis and y-axis direction of the tilt value.
In fact, I also write code to find the regular, keep the parameters of the change alone to see the changes in the graph can find the answer.
M11--x axis Scaling
Tilt on m12--y axis
Tilt on m21--x axis
M22--y axis Scaling
Displacement on the offsetx--x axis
Displacement on the offsety--y axis
- <Grid>
- <image height= "206" horizontalalignment= "left" margin= "73,104,0,0" name= "Image1" stretch= "Uniform" Verticalalignment= "Top" width= "139" source= "/transformsample;component/1.jpg" >
- <Image.RenderTransform>
- <matrixtransform matrix= "2,0,0,1,12,6"/>
- </Image.RenderTransform>
- </Image>
- <image height= "206" horizontalalignment= "left" margin= "122,424,0,0" name= "Image2" source= "/transformsample; Component/1.jpg "stretch=" Uniform "verticalalignment=" Top "width=" 136 ">
- <Image.RenderTransform>
- <matrixtransform matrix= "1,-1,0,1,0,137"/>
- </Image.RenderTransform>
- </Image>
- <image height= "206" horizontalalignment= "left" margin= "293,12,0,0" name= "Image3" source= "/transformsample; Component/1.jpg "stretch=" Uniform "verticalalignment=" Top "width=" 139 ">
- <Image.RenderTransform>
- <matrixtransform matrix= "1,0.6,0,1,0,0"/>
- </Image.RenderTransform>
- </Image>
- <image height= "206" horizontalalignment= "left" margin= "269,424,0,0" name= "Image4" source= "/transformsample; Component/1.jpg "stretch=" Uniform "verticalalignment=" Top "width=" 139 ">
- <Image.RenderTransform>
- <matrixtransform matrix= "1,1,0,1,0,0"/>
- </Image.RenderTransform>
- </Image>
- </Grid>
How do you learn about transformations? Personal recommendation a method, very effective, that is------nonsense.
Really, the study effect is very good, hehe.
You can write the code, then change the values constantly, see what's changed, and you'll find the pattern a few more times.
Windows Phone Development (18): Transformers Nineth season