System.Drawing.Drawing2D.HatchBrush.HatchSolidDiamond C# (CSharp) Method

HatchSolidDiamond() static private method

static private HatchSolidDiamond ( CGContext context ) : void
context CGContext
return void
        void HatchSolidDiamond(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchWidth / 2.0f;

            // We will paint two triangles from corners meeting in the middle
            // make sure to offset by half pixels so that the point is actually a point.
            context.MoveTo(-HALF_PIXEL_X,HALF_PIXEL_Y);
            context.AddLineToPoint(2+HALF_PIXEL_X, halfMe - HALF_PIXEL_Y);
            context.AddLineToPoint(-HALF_PIXEL_X, hatchHeight- (1.0f + HALF_PIXEL_Y));
            context.ClosePath();
            context.FillPath();

            // now we do the right one
            context.MoveTo(hatchWidth,HALF_PIXEL_Y);
            context.AddLineToPoint(halfMe+HALF_PIXEL_X, halfMe - HALF_PIXEL_Y);
            context.AddLineToPoint(hatchWidth, hatchHeight - (1.0f + HALF_PIXEL_Y));
            context.ClosePath();
            context.FillPath();
        }