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

HatchUpwardDiagonal() protected method

protected HatchUpwardDiagonal ( CGContext context ) : void
context CGContext
return void
        protected void HatchUpwardDiagonal(CGContext context)
        {
            var hatchSize = getHatchWidth (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            if (hatchStyle != HatchStyle.ForwardDiagonal &&
                hatchStyle != HatchStyle.BackwardDiagonal)
            {
                initializeContext(context, hatchSize, false);
            }
            else {
                initializeContext(context, hatchSize, true);
            }

            /* draw background */
            drawBackground (context, backColor, hatchSize, hatchSize);

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetFillColor(foreColor.ToCGColor());

            context.SetLineWidth(1);
            context.SetLineCap(CGLineCap.Square);

            context.MoveTo(0,0);
            context.AddLineToPoint(hatchSize,hatchSize);
            /* draw a diagonal line for as many times as linewidth*/
            for (int l = 0; l < lineWidth; l++)
            {
                /* draw a diagonal line */
                context.MoveTo(l,0);
                context.AddLineToPoint(hatchSize, hatchSize-l);

                context.StrokePath();
            }

            /**
             * because we are within a rectangular pattern we have to complete the tip of the preceeding line
             * pattern
             */
            for (int k = 1; k < lineWidth; k++)
            {
                /* draw a diagonal line */
                context.MoveTo(0,hatchSize-k);
                context.AddLineToPoint(k-1, hatchSize-1);

                context.StrokePath();
            }
        }