Painting and animation in WPF (2)

Source: Internet
Author: User

I. The following is a one-on-one explanation:

1. Straight Line

A straight line is the simplest image. You can use the X1 and Y1 attributes to set the start coordinate. The X2 and Y2 attributes are used to set the end coordinate. You can control the coordinates of the start and end points to achieve parallel and staggered effects. The data type of the Stroke attribute is a Brush. Any derived class of the Brush can be used to assign values to this attribute. Since WPF provides a variety of gradient paint brushes, you can draw gradient effects in a straight line. At the same time, some Line attributes also help us draw dotted lines and control the shape of the end point of a Line segment.

The following examples combine these attributes:

<Window x: Class = "WpfApplication1.MainWindow"

Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"

Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"

Title = "Lines" Height = "260" Width = "300">

<Grid>

<Line X1 = "10" Y1 = "20" X2 = "260" Y2 = "20"/>

<Line X1 = "10" Y1 = "40" X2 = "260" Y2 = "40" Stroke = "Orange" StrokeThickness = "6"/>

<Line X1 = "10" Y1 = "60" X2 = "260" Y2 = "60" Stroke = "Green" StrokeThickness = "3"/>

<Line X1 = "10" Y1 = "80" X2 = "260" Y2 = "80" Stroke = "Purple" StrokeThickness = "2"/>

<Line X1 = "10" Y1 = "100" X2 = "260" Y2 = "100" Stroke = "Black" StrokeThickness = "1"/>

<Line X1 = "10" Y1 = "120" X2 = "260" Y2 = "120" StrokeDashArray = "3" Stroke = "Black" StrokeThickness = "1"/>

<Line X1 = "10" Y1 = "140" X2 = "260" Y2 = "140" StrokeDashArray = "5" Stroke = "Black" StrokeThickness = "1"/>

<Line X1 = "10" Y1 = "160" X2 = "260" Y2 = "160" Stroke = "Black" StrokeEndLineCap = "Flat" StrokeThickness = "6"/>

<Line X1 = "10" Y1 = "180" X2 = "260" Y2 = "180" Stroke = "Black" StrokeEndLineCap = "Triangle" StrokeThickness = "8"/>

<Line X1 = "10" Y1 = "200" X2 = "260" Y2 = "200" StrokeEndLineCap = "Round" StrokeThickness = "10">

<Line. Stroke>

<LinearGradientBrush EndPoint = "0, 0.5" StartPoint = "1, 0.5">

<GradientStop Color = "Blue"/>

<GradientStop Offset = "1"/>

</LinearGradientBrush>

</Line. Stroke>

</Line>

</Grid>

</Window>

The actual result 1 is as follows:

 

From the wangganggang90 Column

Related Article

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.