当前位置: 首页>>代码示例>>C#>>正文


C# CGContext.SetFillColor方法代码示例

本文整理汇总了C#中MonoMac.CoreGraphics.CGContext.SetFillColor方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetFillColor方法的具体用法?C# CGContext.SetFillColor怎么用?C# CGContext.SetFillColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MonoMac.CoreGraphics.CGContext的用法示例。


在下文中一共展示了CGContext.SetFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillEllipsis

 public static void FillEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetFillColor(color);
     context.AddEllipseInRect(rect);
     context.FillPath();
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:8,代码来源:CoreGraphicsHelper.cs

示例2: DrawInContext

		public override void DrawInContext (CGContext context)
		{
			base.DrawInContext (context);
			
			context.AddEllipseInRect (Bounds);
			context.SetFillColor (ClockColor);
			context.FillPath ();
		}
开发者ID:Anomalous-Software,项目名称:monomac,代码行数:8,代码来源:ClockLayer.cs

示例3: FillRect

 public static void FillRect(CGContext context, RectangleF rect, CGColor color)
 {
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     context.SetFillColor(color);
     context.FillRect(rect);
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例4: RenderPixels

        void RenderPixels(CGContext context, int x, int y, Edge edge32, Edge edge13, Edge edge21, int w1, int w2, int w3)
        {
            //VertexInterpoliation = A * x + B * y + C;
            //			float alpha = (edge32.A * x + edge32.B * y + edge32.C) * edge32.VertexFactor;
            //			float beta = (edge13.A * x + edge13.B * y + edge13.C)  * edge13.VertexFactor;
            //			float gamma = (edge21.A * x + edge21.B * y + edge21.C) * edge21.VertexFactor;

            // Determine barycentric coordinates
            float alpha = (float)(w1 * edge32.VertexFactor);
            float beta = (float)(w2 * edge13.VertexFactor);
            float gamma = (float)(w3 * edge21.VertexFactor);

            GradientLerp3 (alpha, beta, gamma);
            // Set the color
            context.SetFillColor (colorOutput [0], colorOutput [1], colorOutput [2], colorOutput [3]);

            // Set our pixel location
            pixelRect.X = x;
            pixelRect.Y = y;

            // Fill the pixel
            context.FillRect (pixelRect);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:23,代码来源:PathGradientBrush.cs

示例5: HatchDottedDiamond

        void HatchDottedDiamond(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;
            float quarter = halfMe / 2.0f;

            // this is really just 6 dots that when tiled will
            // create the effect we are looking for
            RectangleF rect = new RectangleF(0,0,1,1);
            setPixels(context, rect);

            rect.Y = halfMe;
            setPixels(context, rect);

            rect.X = halfMe;
            setPixels(context, rect);

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

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

            rect.X = halfMe + quarter;
            rect.Y = halfMe + quarter;
            setPixels(context, rect);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:42,代码来源:HatchBrush.cs

示例6: HatchDivot

        void HatchDivot(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;

            // draw a little wirly thingy
            RectangleF rect = new RectangleF(0,0,1,1);
            setPixels(context, rect);

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

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

            // now top one
            rect.X = halfMe;// + HALF_PIXEL_X;
            rect.Y = halfMe;// + HALF_PIXEL_Y;
            setPixels(context, rect);

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

            rect.X += 1;
            rect.Y += 1;
            setPixels(context, rect);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:44,代码来源:HatchBrush.cs

示例7: HatchConfetti

        void HatchConfetti(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 confetti Rectangles in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());

            RectangleF rect = new RectangleF(0,0,2,2);

            // Do not see a mathematical equation so will just set
            // the same ones as in windows pattern.
            if (hatchStyle == HatchStyle.LargeConfetti)
            {
                setPixels(context, rect);

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

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

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

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

                rect.X = 1;
                rect.Y = 5;
                setPixels(context, rect);
            }
            else
            {
                rect.Width = 1;
                rect.Height = 1;

                setPixels(context, rect);

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

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

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

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

                rect.X = 4;
                rect.Y = 5;
                setPixels(context, rect);

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

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

            }
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:79,代码来源:HatchBrush.cs

示例8: HatchCheckered

        void HatchCheckered(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);

            context.SetFillColor(foreColor.ToCGColor());

            RectangleF rect = new RectangleF(0,0,hatchWidth / 2.0f,hatchHeight / 2.0f);
            setPixels(context, rect);

            rect.X = hatchWidth / 2.0f;
            rect.Y = hatchHeight / 2.0f;
            setPixels(context, rect);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:20,代码来源:HatchBrush.cs

示例9: HatchPlaid

        void HatchPlaid(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;
            RectangleF rect = new RectangleF(0,0,1,1);

            // fraw the alternating pattern for half of area
            int x = 0;
            int y = 0;

            for (y = 0; y<halfMe; y+=2)
            {
                for (x = 1; x < hatchWidth; x+=2)
                {
                    rect.X = x;
                    rect.Y = y;
                    setPixels(context, rect);
                }
            }
            for (y = 1; y<halfMe; y+=2)
            {
                for (x = 0; x < hatchWidth; x+=2)
                {
                    rect.X = x;
                    rect.Y = y;
                    setPixels(context, rect);
                }
            }

            // draw a square
            rect.X = 0;
            rect.Y = halfMe;
            rect.Width = halfMe;
            rect.Height = halfMe;
            setPixels(context, rect);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:50,代码来源:HatchBrush.cs

示例10: HatchPercentage

        /**
         * Percentage patterns were obtained by creating a screen shot from a windows fill
         * and looking at the patterns at the pixel level.  A little tedious to say the least
         * but they do seem correct and recreate the same pattern from windows to here.
         */
        protected void HatchPercentage(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* some patterns require us to reverse the colors */
            switch (hatchStyle) {
            case HatchStyle.Percent05:
            case HatchStyle.Percent10:
            case HatchStyle.Percent20:
            case HatchStyle.Percent25:
            case HatchStyle.Percent30:
                drawBackground (context, backColor, hatchWidth, hatchWidth);
                context.SetFillColor(foreColor.ToCGColor());
                break;
            default:
                drawBackground (context, foreColor, hatchWidth, hatchWidth);
                context.SetFillColor(backColor.ToCGColor());
                break;
            }

            // create a work rectangle for setting pixels
            RectangleF rect = new RectangleF(0,0,1,1);

            // Only set the pixels for some
            if (hatchStyle != HatchStyle.Percent50 &&
                hatchStyle != HatchStyle.Percent40 &&
                hatchStyle != HatchStyle.Percent30 &&
                hatchStyle != HatchStyle.Percent60)
            {
                rect.X = 0;
                rect.Y = (int)(hatchHeight / 2.0f);
                setPixels(context, rect);
                rect.X = (int)(hatchWidth / 2.0f);
                rect.Y = 0;
                setPixels(context, rect);
            }

            // 50 and 40 start out the same with a 50 percent
            if (hatchStyle == HatchStyle.Percent50 ||
                hatchStyle == HatchStyle.Percent40 )
            {
                int x = 0;
                int y = 0;

                for (y = 0; y<hatchHeight; y+=2)
                {
                    for (x = 1; x < hatchWidth; x+=2)
                    {
                        rect.X = x;
                        rect.Y = y;
                        setPixels(context, rect);
                    }
                }
                for (y = 1; y<hatchHeight; y+=2)
                {
                    for (x = 0; x < hatchWidth; x+=2)
                    {
                        rect.X = x;
                        rect.Y = y;
                        setPixels(context, rect);
                    }
                }

                // Percent40 is a 50 with two more dots set of back color
                // within a set area.  This creates an interesting effect
                // of a double plus sign in opposite corners.
                if (hatchStyle == HatchStyle.Percent40)
                {
                    rect.X = 1;
                    rect.Y = 1;
                    setPixels(context, rect);
                    rect.X = 5;
                    rect.Y = 5;
                    setPixels(context, rect);
                }

            }

            // Percent30 and Percent60 are really messed up so we will just set some dots
            // to present the pattern.  Percent60 is a 30 with colors reversed, go figure.
            if (hatchStyle == HatchStyle.Percent30 ||
                hatchStyle == HatchStyle.Percent60)
            {
                rect.X = 0;
                rect.Y = 0;
                setPixels(context, rect);
                rect.X = 2;
                rect.Y = 0;
                setPixels(context, rect);
                rect.X = 0;
                rect.Y = 2;
//.........这里部分代码省略.........
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:101,代码来源:HatchBrush.cs

示例11: HatchSphere

        /**
         * This is fill of hackish stuff.
         * Thought this was going to be easier but that just did not work out.
         **/
        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
            RectangleF rect = new RectangleF(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);

//.........这里部分代码省略.........
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:101,代码来源:HatchBrush.cs

示例12: HatchWeave

        void HatchWeave(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());

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

            float halfWidth = hatchWidth / 2.0f;
            float halfHeight = hatchHeight / 2.0f;

            RectangleF rect = new RectangleF(0,0,1,1);

            // Add upward diagonals
            context.MoveTo(0,0);
            context.AddLineToPoint(halfWidth, halfHeight);
            context.StrokePath();

            context.MoveTo(0, halfHeight);
            context.AddLineToPoint(halfWidth -1, hatchHeight - 1);
            context.StrokePath();

            context.MoveTo(halfWidth, 0);
            context.AddLineToPoint(6, 2);
            context.StrokePath();

            //			context.MoveTo(0, 4);
            //			context.AddLineToPoint(2, 2);
            //			context.StrokePath();

            context.MoveTo(2,6);
            context.AddLineToPoint(7, 1);
            context.StrokePath();
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:45,代码来源:HatchBrush.cs

示例13: DrawPolkaDotPattern

 // Purple poka dots test
 protected void DrawPolkaDotPattern(CGContext context)
 {
     context.SetFillColor(Color.Purple.ToCGColor());
     context.FillEllipseInRect (new RectangleF (4, 4, 8, 8));
 }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:6,代码来源:HatchBrush.cs

示例14: HatchWave

        void HatchWave(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());

            RectangleF rect = new RectangleF(0,0,1,1);

            // We could maybe draw some arcs here but there are so few pixels
            // that it just is not worth it.
            rect.X = 1;
            setPixels(context, rect);
            rect.X = 2;
            setPixels(context, rect);

            rect.Y = 1;

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

            rect.Y = 2;

            rect.X = 4;
            setPixels(context, rect);
            rect.X = 5;
            setPixels(context, rect);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:39,代码来源:HatchBrush.cs

示例15: HatchSolidDiamond

        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();
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:34,代码来源:HatchBrush.cs


注:本文中的MonoMac.CoreGraphics.CGContext.SetFillColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。