Shapes in XPS are geometries painted with brushes. Both can be written as elements or, more compactly, as attribute strings; the page’s units are 1/96 inch.
Geometry elements
| Element | Attributes | Content |
|---|---|---|
PathGeometry | Figures (abbreviated syntax), FillRule (EvenOdd default, NonZero), Transform | PathFigure elements. |
PathFigure | StartPoint (required), IsClosed, IsFilled (default true) | Segments, at least one. |
PolyLineSegment | Points, IsStroked | Straight lines. |
PolyBezierSegment | Points (three per curve), IsStroked | Cubic Bézier curves. |
PolyQuadraticBezierSegment | Points (two per curve), IsStroked | Quadratic curves. |
ArcSegment | Point, Size (radii), RotationAngle, IsLargeArc, SweepDirection (Clockwise, Counterclockwise), IsStroked | An elliptical arc. |
Points are written x,y, separated by spaces.
Abbreviated geometry syntax
Used in Path.Data, Clip and PathGeometry.Figures.
Upper-case commands take absolute coordinates, lower-case ones relative.
| Command | Parameters | Meaning |
|---|---|---|
F | 0 or 1 | Fill rule, only as the first command: 0 even-odd (the default), 1 non-zero. Not allowed in PathGeometry.Figures, which has its own FillRule attribute. |
M, m | x,y | Move: starts a new figure. |
L, l | x,y … | Lines. |
H, h | x | Horizontal line. |
V, v | y | Vertical line. |
C, c | x1,y1 x2,y2 x,y | Cubic Bézier. |
Q, q | x1,y1 x,y | Quadratic Bézier. |
S, s | x2,y2 x,y | Smooth cubic Bézier: the first control point mirrors the previous one. |
A, a | rx,ry angle large sweep x,y | Elliptical arc; large and sweep are 0 or 1. |
Z, z | Close the figure. |
Transforms
A transform is an affine matrix of six numbers,
m11,m12,m21,m22,offsetX,offsetY, written as an attribute value or as
<MatrixTransform Matrix="…"/>. A point (x, y) becomes
(x·m11 + y·m21 + offsetX, x·m12 + y·m22 + offsetY).
Brushes
| Brush | Attributes |
|---|---|
SolidColorBrush | Color (required), Opacity. An attribute such as Fill="#FF0000" is a shorthand for it. |
ImageBrush | ImageSource (a JPEG, PNG, TIFF or JPEG XR part in the package, or {ColorConvertedBitmap image profile}), Viewbox, Viewport, ViewboxUnits and ViewportUnits (Absolute), TileMode (None, Tile, FlipX, FlipY, FlipXY), Transform, Opacity. |
VisualBrush | Visual (a Canvas, Path or Glyphs, often a resource), with the same tiling attributes as ImageBrush. |
LinearGradientBrush | StartPoint, EndPoint, MappingMode (Absolute), SpreadMethod (Pad, Reflect, Repeat), ColorInterpolationMode (SRgbLinearInterpolation, ScRgbLinearInterpolation), Transform, Opacity; LinearGradientBrush.GradientStops. |
RadialGradientBrush | Center, GradientOrigin, RadiusX, RadiusY, and the other gradient attributes. |
GradientStop | Color, Offset, both required. The gradient runs from offset 0.0 to 1.0; stops outside that range only shape the colour at the ends, and missing stops at 0.0 and 1.0 are filled in. |
For an image, Viewbox is in units of 1/96 inch of the image, turned
into source pixels through the image’s resolution (pixel = dpi × value / 96);
Viewport places that box on the page, and tiling repeats it.
Colour syntax
| Form | Meaning |
|---|---|
#RRGGBB | sRGB, opaque. |
#AARRGGBB | sRGB with alpha. |
sc#R,G,B, sc#A,R,G,B | scRGB, floating-point values; with four values the first is alpha (clamped to 0.0–1.0), with three alpha is 1.0. |
ContextColor /profile.icc A,C1,C2,… | A colour in an ICC profile’s space (grey, CMYK, n-channel and named colours): alpha, then one value per channel. |
Sources
- ECMA-388 – Open XML Paper Specification, first edition (2009): §11.2 geometries, figures and the abbreviated syntax, §13 brushes (tiling, Viewbox units, gradients), §14.4 transforms, §15.2 vector colour syntax, §18.3 gradient computations, §19 element reference