Making materials in WPF: A contest between picture and vector graphics

Source: Internet
Author: User
Tags scalar

If you want to do one of these things as a background. How would you do it?

Figure 1. Target background effect

Plan one, use PS to draw out. Then take the PNG picture as the background color. This scheme can be, but what if you want the color of this line to be configurable? How is the thickness of the line uncertain? No matter which problem, the way of pixel graph is difficult to solve.

Scenario two, drawing with a vector graph of WPF. This scheme can easily solve the above two problems.

But no matter which way we use it, we don't draw the whole size of the picture. Instead, the drawing is a minimal entity, and then repeats.

Scalar graph Scheme

For the scalar of PS painting, there is a picture below. It then repeats indefinitely within the area to be drawn. Especially do the material on the page is so, to know the size of the picture is not more than the text, all the pictures can be a big picture. and visual designer will be more tired to change.

Figure 2. PNG material picture (enlarged)

For example, the figure is called Twill.png, the size is 6*6. Then use this entity in WPF to create the following code for the material in Figure 1.

<DrawingBrush x:Key="PicTwillBrush"
                       Stretch="Fill"  TileMode="Tile"
                       Viewport="0,0,6,6"  ViewportUnits="Absolute">
             <DrawingBrush.Drawing>
                 <ImageDrawing ImageSource="Textures\Twill.png"  Rect="0,0,6,6"/>
             </DrawingBrush.Drawing>
         </DrawingBrush>

By default, this is the perfect material for the solution, which is perfect with fig. 1. But if you use Viewbox to put this picture down, the following phenomenon will appear.

Figure 3. Achieve rendering effect (Viewbox amplification)

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.