Windows Phone Development (18): Transformers Nineth season

Source: Internet
Author: User

Tags: how hot site orm Fill rectangle off COM translate

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.

  1. <Canvas>
  2. <!--three rectangles are in the same position in the canvas, but after panning the transform,
  3. It looks as if it's not in the same position.
  4. -
  5. <rectangle width= "height=" 120 "
  6. Fill= "Darkgreen"
  7. canvas.zindex= "0"
  8. canvas.top= "15"
  9. Canvas.left= ">"
  10. <Rectangle.RenderTransform>
  11. <translatetransform x= "y="/>
  12. </Rectangle.RenderTransform>
  13. </Rectangle>
  14. <rectangle width= "height=" 120 "
  15. Fill= "Yellow"
  16. canvas.zindex= "1"
  17. canvas.top= "15"
  18. Canvas.left= ">"
  19. <Rectangle.RenderTransform>
  20. <translatetransform x= "y="/>
  21. </Rectangle.RenderTransform>
  22. </Rectangle>
  23. <rectangle width= "height=" 120 "
  24. Fill= "Blue"
  25. canvas.zindex= "2"
  26. canvas.top= "15"
  27. Canvas.left= ">"
  28. <Rectangle.RenderTransform>
  29. <translatetransform x= "y="/>
  30. </Rectangle.RenderTransform>
  31. </Rectangle>
  32. </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.

  1. <Grid>
  2. <image margin= "289,42,241,143" source= "/transformsample;component/1.jpg" stretch= "Uniform" Opacity= "0.3"
  3. rendertransformorigin= "0.5,1" >
  4. <Image.RenderTransform>
  5. <rotatetransform angle= " -60"/>
  6. </Image.RenderTransform>
  7. </Image>
  8. <image margin= "289,42,241,143" source= "/transformsample;component/1.jpg" stretch= "Uniform" Opacity= "0.6"
  9. rendertransformorigin= "0.5,1" >
  10. <Image.RenderTransform>
  11. <rotatetransform angle= "0"/>
  12. </Image.RenderTransform>
  13. </Image>
  14. <image margin= "289,42,241,143" source= "/transformsample;component/1.jpg" stretch= "Uniform"
  15. rendertransformorigin= "0.5,1" >
  16. <Image.RenderTransform>
  17. <rotatetransform angle= "/>"
  18. </Image.RenderTransform>
  19. </Image>
  20. </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.

  1. <Grid>
  2. <image source= "/transformsample;component/1.jpg" stretch= "Uniform" horizontalalignment= "Center" Verticalalignment= "Center" margin= "130"
  3. canvas.zindex= "0" opacity= "0.09" >
  4. <Image.RenderTransform>
  5. <scaletransform centerx= "centery=" scalex= "2" scaley= "2"/>
  6. </Image.RenderTransform>
  7. </Image>
  8. <image source= "/transformsample;component/1.jpg" stretch= "Uniform" horizontalalignment= "Center" Verticalalignment= "Center" margin= "130"
  9. canvas.zindex= "1" opacity= "0.2" >
  10. <Image.RenderTransform>
  11. <scaletransform centerx= "centery=" scalex= "1.6" scaley= "1.6"/>
  12. </Image.RenderTransform>
  13. </Image>
  14. <image source= "/transformsample;component/1.jpg" stretch= "Uniform" horizontalalignment= "Center" Verticalalignment= "Center" margin= "130"
  15. canvas.zindex= "2"/>
  16. </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.

  1. <Grid>
  2. <image source= "/transformsample;component/1.jpg" horizontalalignment= "Center"
  3. Verticalalignment= "Center"
  4. Margin= "/>"
  5. <image source= "/transformsample;component/1.jpg" horizontalalignment= "Center"
  6. Verticalalignment= "Center"
  7. margin= "opacity=" "0.3" >
  8. <Image.RenderTransform>
  9. <skewtransform centerx= "0" centery= " -200" anglex= "" angley= "0"/>
  10. </Image.RenderTransform>
  11. </Image>
  12. <image source= "/transformsample;component/1.jpg" horizontalalignment= "Center"
  13. Verticalalignment= "Center"
  14. margin= "opacity=" "0.3" >
  15. <Image.RenderTransform>
  16. <skewtransform centerx= "0" centery= " -550" anglex= " -15" angley= "0"/>
  17. </Image.RenderTransform>
  18. </Image>
  19. </Grid>


Five, TransformGroup.


Strictly speaking, this is not a transformation, but it can be achieved by adding n transformations together.

  1. <Grid>
  2. <image source= "/transformsample;component/1.jpg"
  3. Stretch= "Uniform" margin= "65,98,472,92"/>
  4. <image source= "/transformsample;component/1.jpg"
  5. Stretch= "Uniform" margin= "65,98,472,92" >
  6. <Image.RenderTransform>
  7. <TransformGroup>
  8. <translatetransform x= "y="/>
  9. <scaletransform scalex= "1.5" scaley= "1.5" centerx= "185" centery= "280"/>
  10. <rotatetransform centerx= "centery=" angle= "/>"
  11. </TransformGroup>
  12. </Image.RenderTransform>
  13. </Image>
  14. </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

  1. <Grid>
  2. <image source= "/transformsample;component/1.jpg" stretch= "Uniform" margin= "48,68,492,131"/>
  3. <image source= "/transformsample;component/1.jpg" stretch= "Uniform" margin= "48,68,492,131"
  4. opacity= "0.5" >
  5. <Image.RenderTransform>
  6. <compositetransform
  7. centerx= "" centery= "185"
  8. Rotation= "45"
  9. skewx= "skewy=" 15 "
  10. scalex= "1.2" scaley= "1.2"
  11. translatex= "translatey=" "/>"
  12. </Image.RenderTransform>
  13. </Image>
  14. </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

  1. <Grid>
  2. <image height= "206" horizontalalignment= "left" margin= "73,104,0,0" name= "Image1" stretch= "Uniform" Verticalalignment= "Top" width= "139" source= "/transformsample;component/1.jpg" >
  3. <Image.RenderTransform>
  4. <matrixtransform matrix= "2,0,0,1,12,6"/>
  5. </Image.RenderTransform>
  6. </Image>
  7. <image height= "206" horizontalalignment= "left" margin= "122,424,0,0" name= "Image2" source= "/transformsample; Component/1.jpg "stretch=" Uniform "verticalalignment=" Top "width=" 136 ">
  8. <Image.RenderTransform>
  9. <matrixtransform matrix= "1,-1,0,1,0,137"/>
  10. </Image.RenderTransform>
  11. </Image>
  12. <image height= "206" horizontalalignment= "left" margin= "293,12,0,0" name= "Image3" source= "/transformsample; Component/1.jpg "stretch=" Uniform "verticalalignment=" Top "width=" 139 ">
  13. <Image.RenderTransform>
  14. <matrixtransform matrix= "1,0.6,0,1,0,0"/>
  15. </Image.RenderTransform>
  16. </Image>
  17. <image height= "206" horizontalalignment= "left" margin= "269,424,0,0" name= "Image4" source= "/transformsample; Component/1.jpg "stretch=" Uniform "verticalalignment=" Top "width=" 139 ">
  18. <Image.RenderTransform>
  19. <matrixtransform matrix= "1,1,0,1,0,0"/>
  20. </Image.RenderTransform>
  21. </Image>
  22. </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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: