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

HatchSphere() protected method

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

            initializeContext(context, hatchSize, false);

            /* draw background in fore ground color*/
            drawBackground (context, backColor, hatchSize, hatchSize);

            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetFillColor(foreColor.ToCGColor());

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

            // Initialize work rectangle
            CGRect rect = new CGRect (0,0,1,1);

            float quad = hatchSize / 2.0f;

            // Left lower quad
            rect.Width = quad;
            rect.Height = quad;
            rect.X = 0;
            rect.Y = 0;

            context.StrokeRect(rect);

            // right upper quad
            rect.Width = quad;
            rect.Height = quad;
            rect.X = quad;
            rect.Y = quad;

            context.StrokeRect(rect);

            // left upper quad
            rect.Width = quad;
            rect.Height = quad;
            rect.X = 0;
            rect.Y = quad + 1;

            context.FillRect(rect);

            // right lower quod
            rect.Width = quad;
            rect.Height = quad;
            rect.X = quad + 1;
            rect.Y = 0;

            context.FillRect(rect);

            // Now we fill in some corner bits with background
            // This is a bad hack but now sure what else to do
            context.SetFillColor(backColor.ToCGColor());

            rect.Height = 1;
            rect.Width = 1;

            rect.X = 0;
            rect.Y = 0;
            setPixels (context, rect);

            rect.X = 0;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = 0;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = quad;
            rect.Y = 0;
            setPixels(context, rect);

            rect.X = quad;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = quad;
            rect.Y = hatchSize;
            setPixels(context, rect);

            rect.X = hatchSize;
            rect.Y = 0;
            setPixels(context, rect);

            rect.X = hatchSize;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = hatchSize;
            rect.Y = hatchSize;
            setPixels(context, rect);

            // Now for the fake shiny thingys hack
            // Probably could use a line here but it is already
            // so hacky I will just use this.
            rect.X = 5;
            rect.Y = 3;
            setPixels(context, rect);

            rect.X = 6;
            rect.Y = 3;
            setPixels(context, rect);

            rect.X = 1;
            rect.Y = 7;
            setPixels(context, rect);

            rect.X = 2;
            rect.Y = 7;
            setPixels(context, rect);
        }