"Miles Journey--windows App development" brushes and images

Source: Internet
Author: User

The brush must not be unfamiliar to everyone, here is a systematic introduction of the good. Let's introduce a solid color brush.

The simplest solid color brushes are already defined names, such as red and green, which are said to have a total of 256 named, so the basic is enough. The XAML parser automatically links these color names to the color structure.

There is also the legendary hexadecimal color value, which defines an exact 24-bit color value, with 8 bits for SolidColorBrush. As shown in the following code, alpha= "FF", red = "55", green = "00", Blue = "88".

<Rectangle Width="200" Height="100" Fill="#FF550088" />

There is also a syntax called attribute element. Here's how to use it, opacity is transparency.

  <Rectangle Width="200" Height="100">     <Rectangle.Fill>        <SolidColorBrush Color="Yellow" Opacity="0.3" />     </Rectangle.Fill>  </Rectangle>

In addition to the solid color brush, there are also gradient brushes. When I was a child, I liked the gradient brush most when I learned Photoshop.

The LinearGradientBrush will be graded along a line called the gradient axis to draw an area. We still take rectangle to do the example.

   <Rectangle Width= "Max" Height=" +" >            <rectangle.fill>                <LinearGradientBrush StartPoint="0,0" EndPoint=" the" >                    <gradientstop Color="Green" Offset="0.0" x: Name="GradientStop1"/>                    <gradientstop Color="Blue" Offset="0.25" x:name=  "GradientStop2"/>                    <gradientstop Color="Wheat"Offset="0.7" x:name ="GradientStop3"/>                      <gradientstop Color="Yellow" Offset="0.75" x:name= "GRADIENTSTOP4"/>                    <gradientstop Color="Gold" Offset="1.0" x:name ="GradientStop5"/>                </LinearGradientBrush>            </Rectangle.fill>        </Rectangle>

By changing the attribute values of StartPoint and endpoint, you can create various gradients, such as vertical and horizontal gradients, invert the gradient direction, and even speed up the gradient.

In addition to the use of two kinds of brushes, you can also directly add the picture in it.

<Ellipse Height="100" Width="200">            <Ellipse.Fill>                <ImageBrush ImageSource="9327.jpg" />            </Ellipse.Fill>        </Ellipse>

The effect is as follows, mainly has a suitable picture.

Now that you've used the ImageBrush, take a look at the difference between the image and the ImageBrush. The former is used primarily to render the image, while the latter is drawn as an image for other objects.

For image, we can stretch the image, that is, the stretch property.

None: The image is not stretched. If the source image is larger than the area that is left for image, it is clipped.
Uniform: Scales the image by aspect ratio.
UniformToFill: Fills all areas by aspect ratio, which means that some of them may not be visible.
Fill. Because the aspect ratio is not retained to fill the screen, parts of the image are all visible, but the picture is distorted (distorted).
See the specific effect (from the network).

The Clip property allows you to crop the image, which is used many times in the previous blog, the first 2 values are the x and Y coordinates of the starting point, and the last 2 values are the X-and y-axis coordinates of the end points.

<Image Source="9327.jpg">    <Image.Clip>        <RectangleGeometry Rect="10,10,100,100"/>    </Image.Clip></Image>

What are the image formats that image and ImageBrush can handle?
JPEG XR
Icon (ICO)
Bitmap (BMP)
Image Interchange Format (GIF)
Joint Image Expert Group (JPEG)
Portable Network Image (PNG)
Tagged Image File format (tief)

"Miles Journey--windows App development" brushes and images

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.