Bagikan melalui


Drawing shapes and paths

Microsoft Expression Blend offers standard vector drawing capabilities so that you can draw shapes, paths, and masks just as you would in any vector graphics program. For more advanced drawings and artwork, consider using an alternative vector graphic program such as Microsoft Expression Design. Expression Design even lets users export drawings as XAML for use in Expression Blend.

For more information, see Import XAML that is exported from Expression Design.

What are vector graphics?

Vector graphics are defined geometrically by points, lines, curves, and surfaces, instead of using pixels as in a bitmap. As monitors for computers incorporate higher resolution displays, there is a need to move away from bitmaps, which show large pixels when viewed at a high resolution. The resizing of bitmaps can be awkward, and they generally lead to poor-quality graphics. Vector graphics remain smooth when viewed at a high resolution, and remain sharp when resized larger. For this reason, vector graphics are easier to customize around content, because you do not have to create multiple images at different sizes (for example, icon files that appear in the user interface [UI] at various sizes). Other benefits of vector graphics include the following:

  • True content scaling   Vector graphics built into a flexible layout can resize elegantly based on content. For example, when you add text to a button, the button will resize accordingly without compromising the fidelity of the graphic.

  • Resolution independence   The resolution of displays has been gradually increasing and will likely continue to do so. Without the ability to scale an application's UI, the UI becomes smaller as the resolution increases, typically becoming unusable when the content appears so small that it becomes unreadable. If you apply a scaling or rotation transform with these APIs, it affects only the drawings. There is no effect on the sizes and positions of controls in the window. You can scale drawings, but you can't easily scale the way that a window's space is carved up by controls. Because Windows Presentation Foundation (WPF) composes all the controls in the window as a single drawing, instead of segregating each control to its own region, it is easy to apply scaling or rotation transformations to the UI as a whole. Thus, because you can scale any WPF UI up or down, WPF applications are effectively resolution-independent. Images remain sharp and clear, instead of becoming the blur you would expect from simple bitmap scaling.

Note

When setting size-related properties in WPF applications (such as those created by using Expression Blend), pixels refer to device-independent pixels or device-independent units that are equivalent to the size of a pixel on a monitor when it is set to a screen resolution of 96 DPI. Each unit is approximately 1/96 inch, regardless of monitor size or screen resolution.

In Expression Blend, a vector object can be as simple as a line or shape, or as complex as a path or control. Objects can be modified in many ways by using on-object handles for resizing, moving, rotating, flipping, or skewing objects, or by using the Properties panel, where you can enter precise values for size, position, and rotation. Basically, every object you draw onto the artboard is in vector format except for those items that you've added to your project that weren't originally in vector format, such as images and 3D textures. Some of the vector objects in Expression Blend include the following:

  • Drawing objects such as ellipses and rectangles.

  • Path objects such as lines and curves.

  • Text.

  • 3D objects.

  • Controls.

Drawing tools

In the Tools panel, you'll find common vector tools for creating shape and path elements, and for manipulating objects.

For examples of using these tools, see the following topics:

Tool Name Use to
Cc295296.81ffc148-cf5c-4faf-bd3f-f38d3073a12c(en-us,Expression.40).png

Rectangle

Draw rectangles and squares, which you can also modify to have rounded corners.

Cc295296.8938cfdf-9b75-4a33-bc88-b0636e114a0d(en-us,Expression.40).png

Ellipse

Draw ellipses and circles.

Cc295296.eb618397-5283-48be-8396-3449be7b6fbf(en-us,Expression.40).png

Line

Draw a straight line between two points.

Cc295296.894f8612-e0ed-4e00-84cf-a9bc8f38fc54(en-us,Expression.40).png

Pen

Draw and modify paths where you define each node. The Pen tool lets you add, remove, and modify nodes in the path.

Cc295296.509dc167-734f-46c9-b012-987ee63450cd(en-us,Expression.40).png

Pencil

Draw freehand paths.

Cc295296.2ff91340-477e-4efa-a0f7-af20851e4daa(en-us,Expression.40).png

Selection

Select shapes, paths, and objects on the artboard that you want to modify.

For more information about how to use the Selection tool, see Select or cancel the selection of objects.

Cc295296.6dd6571f-c116-451d-8dd2-1f88b8406362(en-us,Expression.40).png

Direct Selection

Select individual nodes on a path after they have been drawn. You can also use the Direct Selection tool to directly select child objects nested inside a parent object on the artboard, such as a layout panel.

For more information about how to use the Direct Selection tool, see Select or cancel the selection of objects.

Shapes and paths

Shapes, such as rectangles and ellipses, are vector objects. You draw shapes with the Rectangle tool Cc295296.81ffc148-cf5c-4faf-bd3f-f38d3073a12c(en-us,Expression.40).png or the Ellipse tool Cc295296.8938cfdf-9b75-4a33-bc88-b0636e114a0d(en-us,Expression.40).png.

Paths, which are also vector objects, are arguably the most flexible vector objects in Expression Blend. Paths are a series of connected lines and curves. After you draw paths onto the artboard, you can reshape, combine, and otherwise modify them to create any vector shape. You can draw polygons, which are closed shapes consisting of straight, connected lines, in addition to polylines, which are unclosed paths consisting of straight, connected lines. You draw paths with the Pen tool Cc295296.894f8612-e0ed-4e00-84cf-a9bc8f38fc54(en-us,Expression.40).png, the Pencil tool Cc295296.509dc167-734f-46c9-b012-987ee63450cd(en-us,Expression.40).png, and the Line tool Cc295296.eb618397-5283-48be-8396-3449be7b6fbf(en-us,Expression.40).png. You can then use the Selection tool Cc295296.2ff91340-477e-4efa-a0f7-af20851e4daa(en-us,Expression.40).png and the Direct Selection tool Cc295296.6dd6571f-c116-451d-8dd2-1f88b8406362(en-us,Expression.40).png for modifying paths.

For more information about how to modify paths, see the following topics:

Converting shapes to paths

Shape objects cannot be edited the same way as path objects unless you convert the shape object to a path object by using the Convert to Path command (on the Object menu, click Path, and then click Convert to Path).

For an example, see Convert a shape to a path.

Note

You will not be able to change properties that are specific to a shape (such as the corner radius of a rectangle) after converting the shape to a path. Also, if a style was applied to the shape before conversion, the properties of the converted path will be reset to the defaults for a path (no fill brush, and a black stroke).

Changing the corner radius

You can modify the corner radius of a rectangle by selecting the rectangle and then dragging the corner radius handles on the upper-left corner. The corner radius handle appears when your pointer moves over either end of the dotted lines that jut out from the upper-left corner of the rectangle.

Cc295296.b120ec92-5a55-4f25-89a4-da4f63572e47(en-us,Expression.40).png

By holding down SHIFT when you drag either corner radius handle, you can modify the X and Y corner radii individually.

For an example, see Round the corners of a rectangle.

Combining paths

Combining paths (or shapes) can give you the following results:

Cc295296.2df17a5d-a338-4ef4-96c5-dae51cc1ca8a(en-us,Expression.40).png

Cc295296.25182a96-9a69-478a-9cfe-5b360e6a9bea(en-us,Expression.40).png

Two shapes before combining

Cc295296.eb6fad93-f17e-4f62-a926-8c8651862891(en-us,Expression.40).png

Intersect

Cc295296.05fe4b1d-f584-4bd2-99b6-8bc2d735a89d(en-us,Expression.40).png

Unite

Cc295296.a5d608f2-bba2-48c5-8b15-2c115db86acc(en-us,Expression.40).png

Exclude Overlap

Cc295296.f0c1ff71-7814-42ba-806b-7ea92d616e69(en-us,Expression.40).png

Divide

Cc295296.15de085f-48f5-41dd-a286-e3dcb4cfd18b(en-us,Expression.40).png

Subtract

You can combine two or more objects (paths or shapes) into one path object. The resulting path object replaces the last object that was selected before combining, adopting the properties of that object. Often, the result is a compound path.

For an example, see Combine shapes or paths.

For more information about how to modify paths, see Direct Selection tool modifier keys and Pen tool modifier keys.

Note

You will not be able to change properties that are specific to a shape (such as the corner radius of a rectangle) after combining that shape with another object. Also, if a style was applied to the last selected object before conversion, the properties of the combined path will be reset to the defaults for a path (no fill brush, and a black stroke).

Compound paths

When you create a compound path, any intersecting parts of the paths are subtracted from the result, and the resulting path takes on the visual properties of the bottommost path.

Two paths converted to a compound path

Cc295296.2157a8aa-d9a7-4de4-8de5-b10d28f08a84(en-us,Expression.40).png

Shapes must be converted to paths before you include them in a compound path (select Convert to Path under Path on the Object menu). You can make two or more paths into one compound path. The resulting path replaces the bottommost path (in Z-order) that was selected before compounding, adopting the properties of that path. You can break apart a compound path any time after you create it, but the original properties will not be restored.

For an example, see Make or release a compound path.

Clipping paths

A clipping path is a path or shape that is applied to another object, hiding the parts of the masked object that fall outside the clipping path.

Image object with a clipping path applied to it

Cc295296.22471e98-a841-4f39-a3ef-36090cf5a625(en-us,Expression.40).png

In Expression Blend, you can modify clipping paths on the artboard after you create them, and you can release a clipping path without losing the original path object. For an example, see Apply, modify, or remove a clipping path.

You can also animate the individual vertices of clipping paths (for example, to gradually expose the masked object). For an example, see Animate the points on a path or clipping path.

Opacity masks

An opacity mask can be a path or shape that is applied to another object. The transparent parts of the path represent areas where the masked object is faded out, whereas the opaque parts of the mask indicate where the masked object is allowed to show through. Any object can have an opacity mask defined for it through the Appearance section of the Properties panel.

An opacity mask can be a simple gradient brush that shows or hides parts of an object based on transparency. In the following example, the image on the left has no opacity mask applied, and the image on the right could be produced in one of the following two ways:

  • The OpacityMask property of the Image object could be set to a radial gradient brush with the Alpha of the right gradient stop set to a value of 0.

  • A Rectangle object could be created in front of the Image object, and the OpacityMask property of the Rectangle could be set to a radial gradient brush with the Alpha of the left gradient stop set to a value of 0.

Image with no mask (left) versus an image with an opacity mask applied (right)

Cc295296.2bcb0f7e-9e47-4314-8f64-23fdc711510f(en-us,Expression.40).png

For an example, see Create an opacity mask.

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.