// Draw the pattern using the texture brush. void DrawPatternWithTexBrush(GraphicsTarget g, SymPathWithHoles path, float angle, SymColor color, RenderOptions renderOpts) { Brush brush = (Brush) patternBrushes[color]; Debug.Assert(brush != null); if (angle != 0.0F) { object graphicsState = g.Save(); try { // Set the clipping region to draw only inside the area. g.SetClip(path); // use a transform to rotate. Matrix matrix = GraphicsUtil.RotationMatrix(angle, new PointF(0, 0)); g.Transform(matrix); // Get the correct bounding rect. RectangleF bounding = Util.BoundsOfRotatedRectangle(path.BoundingBox, new PointF(), -angle); g.FillRectangle(brush, bounding); } finally { // restore the clip region and the transform g.Restore(graphicsState); } } else { path.Fill(g, brush); } }
// Draw the framing rectangle around some text. The top of the text is at 0, and the bottom baseline of text is at "bottomOfText". private void DrawFramingRectangle(GraphicsTarget g, float[] lineWidths, float fullWidth, SymColor color, float bottomOfText) { if (framing.framingStyle == FramingStyle.Rectangle && color == framing.framingColor) { // First, figure out the width of the rectangle. If fullWidth is zero, used the maximum line width. fullWidth = CalcFullWidth(lineWidths, fullWidth); // Next, figure out the rectangle, not counting padding. float l, t, r, b; if (fontAlign == TextSymDefAlignment.Right) l = -fullWidth; else if (fontAlign == TextSymDefAlignment.Center) l = -(fullWidth / 2F); else l = 0; r = l + fullWidth; t = FontAscent - WHeight; // Place the top of the rectangle at top of letter "W", not top of accents. b = bottomOfText; // Add padding. t -= framing.rectBorderTop; b += framing.rectBorderBottom; l -= framing.rectBorderLeft; r += framing.rectBorderRight; // Draw the rectangle g.FillRectangle(color.Brush, new RectangleF(l, t, r - l, b - t)); } }