For example, if the green star used mitered instead of rounded corners, then the final corner between the first and last point would not be mitered. Unfortunately if the first point in the array duplicates the point used in the call to BeginFigure, then the polyline includes that point twice and that messes up the connection between the last point and the first point. Its first parameter is the array of points that should be connected.
#BRICSCAD HOW MAKE POLYLINES FILLED CODE#
The method uses the value of its draw_polygon parameter so this code closes the shape only if it is drawing a polygon.Īfter starting a new figure, the code calls the context’s PolyLineTo method. The final parameter to BeginFigure indicates whether the shape should be closed. If you don’t want to fill the shape, you can simply pass this method a null brush to make the method “fill” the shape with nothing. The second parameter to BeginFigure indicates whether the shape should be filled. Its first parameter indicates where drawing should start, in this case at the points array’s first point. You need to call this method before you start drawing. It calls the context’s BeginFigure method to start a drawing sequence. Next the program “opens” the StreamGeometry to get a context that it can use to draw. (See the picture.) If this property were set to Nonzero, then the interior of the star would be filled completely. This example uses the EvenOdd setting so there is an unfilled hole in the middle of the green outer star. This can have the values EvenOdd or Nonzero. Because this example doesn’t need those, it uses the lighter-weight StreamGeometry class.)Īfter it creates the StreamGeometry object, the code sets its FillRule property. (The PathGeometry class is similar but heavier because it supports data binding, animation, and modification.
![bricscad how make polylines filled bricscad how make polylines filled](https://forum.bricsys.com/uploads/Uploader/93/8f3127c6d05266b92eccf6cf371c54.jpg)
The StreamGeometry class is a geometry class (there are others such as LineGeometry and RectangleGeometry) that represents a sequence of drawing commands that can include shapes such as lines, arcs, ellipses, and rectangles. This method creates a StreamGeometry object to represent the shape. Using (StreamGeometr圜ontext context = geo.Open())Ĭontext.BeginFigure(points, true, draw_polygon) Ĭontext.PolyLineTo(points.Skip(1).ToArray(), true, false) ĭrawingContext.DrawGeometry(brush, pen, geo) StreamGeometry geo = new StreamGeometry() Make a StreamGeometry to hold the drawing objects.
![bricscad how make polylines filled bricscad how make polylines filled](https://www.digitalengineering247.com/images/article/BricsCAD-3D-Compare_web.jpg)
Private static void DrawPolygonOrPolyline(īrush brush, Pen pen, Point points, FillRule fill_rule, The following code shows the private DrawPolygonOrPolyline method that draws either polygons or polylines. So for this example I decided to add them as extension methods. Logically that class should also provide DrawPolygon, DrawPolyline, and other drawing methods but it doesn’t. The DrawingContext class provides a few drawing methods such as DrawEllipse, DrawLine, and DrawRectangle. If that was Microsoft’s idea, it might have been better if they just didn’t allow this kind of rendering instead of giving us a confusing and poorly-documented method for doing it.Īnyway, with the rant out of the way, let me explain how the program works. It is definitely easier to use that approach. Perhaps Microsoft is trying to “gently” encourage us to use drawing objects (such as the Polygon object) to draw shapes instead of trying to render them in code. (WPF’s slogan should be, “Twice as flexible and only five times as hard!”) However sometimes, as in this example, it makes simple things much harder.
![bricscad how make polylines filled bricscad how make polylines filled](https://i.ytimg.com/vi/Wo1zFK9Gm8Y/maxresdefault.jpg)
#BRICSCAD HOW MAKE POLYLINES FILLED WINDOWS#
WPF lets you do all sorts of interesting things that are much harder in Windows Forms applications.