Path


PathHierarchy: UIElement FrameworkElement Shape StretchableShape

     <Path         Stroke="Black"         Data="M 100 100 L 300 100 L 200 300 z"></Path> 

or:

     <Path         Stroke="Black">         <Path.Data>             <GeometryGroup>                 <LineGeometry StartPoint="100,100" EndPoint="300,100"/>                 <LineGeometry StartPoint="300,100" EndPoint="200,300"/>                 <LineGeometry StartPoint="200,300" EndPoint="100,100"/>             </GeometryGroup>         </Path.Data>     </Path> 

<Path .../> is used to draw a series of lines and curves. Path can use abbreviated inline markup commands (described in Table 9-2) to designate the geometry used when drawing the path, or the geometry can be explicitly declared using a GeometryGroup.

Table 9-2. Abbreviated syntax for subpath declarations

Command

Syntax

Description

Move

M x,y or m x,y

Establishes a new current point. Each path segment must begin with a move command; subsequent move commands indicate the start of a new subpath.

Line

L x,y or l x,y

Draws a straight line from the current point to the specified point.

Horizontal Line

H x or h x

Draws a horizontal line from the current point to the specified x-coordinate.

Vertical Line

V y or v y

Draws a vertical line from the current point to the specified y-coordinate.

Cubic Bezier Curve

C x1,y1 x2,y2 x3,y3 or c x1,y1 x2,y2 x3,y3

Draws a cubic Bezier curve from the current point to the specified point (x3,y3) using the two specified control points (x1,y1 and x2,y2). The first control point determines the beginning of the curve, and the second control point determines the end of the curve.

Quadratic Bezier Curve

Q x1,y1 x2,y2 or q x1,y1 x2,y2

Draws a quadratic Bezier curve from the current point to the specified point (x2,y2) using the specified control point (x1,y1).

Smooth Cubic Bezier Curve

S x1,y1 x2,y2 or s x1,y1 x2,y2

Draws a cubic Bezier curve from the current point to the specified point (x2,y2). The first control point is assumed to be the reflection (relative to the current point) of the previous command's second control point. If there is no previous command or if the previous command was neither a cubic Bezier curve command nor a smooth cubic Bezier curve command, assume the first control point coincides with the current point. The second control pointthe control point for the end of the curveis specified by x1,y1.

Elliptical Arc

A xr,yr rx flag1 flag2 x,y or a xr,yr rx flag1 flag2 x,y

Draws an elliptical arc from the current point to the specified point (x,y). The size and orientation of the ellipse are defined by xr, yr, and rx. xr defines the x-radius, yr defines the y-radius, and rx defines the x-axis rotation in degrees, which indicates how the ellipse is rotated relative to the current coordinate system. The center of the ellipse is calculated automatically.

In most situations, four different arcs satisfy the specified constraints; flag1 and flag2 indicate which arc to use.

Of the four candidate arc sweeps, two represent large arcs with sweeps of 180 degrees or greater, and two represent smaller arcs with sweeps of 180 degrees or less. If flag1 is 1, one of the two larger arc sweeps is chosen; if flag1 is 0, one of the smaller arc sweeps is chosen.

If flag2 is 1, the arc is drawn in a positive-angle direction. If flag2 is 0, the arc is drawn in a negative-angle direction.

Close Path

Z or z

Ends the current subpath and draws a straight line from the current point to the initial point of the current subpath. If a Move command (an M or an m) follows the ClosePath command, the Move command identifies the next subpath's start point. Otherwise, the next subpath starts at the same initial point as the current subpath.


Attributes


Data (required)

Describes the path to be drawn. In XAML, Data can be declared either by declaring instances of specific Geometry types or by using abbreviated syntax to describe subpaths.




XAML in a Nutshell
XAML in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596526733
EAN: 2147483647
Year: 2007
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net