本文整理汇总了C#中CGContext.SetFillColor方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetFillColor方法的具体用法?C# CGContext.SetFillColor怎么用?C# CGContext.SetFillColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.SetFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBorders
void DrawBorders(CGContext context, nfloat xMin, nfloat xMax, nfloat yMin, nfloat yMax, nfloat fWidth, nfloat fHeight)
{
if (BorderColorTop != null)
{
context.SetFillColor(BorderColorTop.CGColor);
context.FillRect(new CGRect(xMin, yMin, fWidth, BorderWidth.Top));
}
if (BorderColorLeft != null)
{
context.SetFillColor(BorderColorLeft.CGColor);
context.FillRect(new CGRect(xMin, yMin, BorderWidth.Left, fHeight));
}
if (BorderColorRight != null)
{
context.SetFillColor(BorderColorRight.CGColor);
context.FillRect(new CGRect(xMax - BorderWidth.Right, yMin, BorderWidth.Right, fHeight));
}
if (BorderColorBottom != null)
{
context.SetFillColor(BorderColorBottom.CGColor);
context.FillRect(new CGRect(xMin, yMax - BorderWidth.Bottom, fWidth, BorderWidth.Bottom));
}
}
示例2: DrawMapRect
/// <summary>
/// Draws the map rectangle.
/// </summary>
/// <param name="mapRect">Map rectangle.</param>
/// <param name="zoomScale">Zoom scale.</param>
/// <param name="context"> Graphics context.</param>
public override void DrawMapRect(MKMapRect mapRect, nfloat zoomScale, CGContext context)
{
base.DrawMapRect(mapRect, zoomScale, context);
var multiPolygons = (MultiPolygon)this.polygonOverlay;
foreach (var item in multiPolygons.Polygons)
{
var path = new CGPath();
this.InvokeOnMainThread(() =>
{
path = PolyPath(item.Polygon);
});
if (path != null)
{
context.SetFillColor(item.FillColor);
context.BeginPath();
context.AddPath(path);
context.DrawPath(CGPathDrawingMode.EOFill);
if (item.DrawOutlines)
{
context.BeginPath();
context.AddPath(path);
context.StrokePath();
}
}
}
}
示例3: DrawInContext
public override void DrawInContext (CGContext context)
{
base.DrawInContext (context);
context.AddEllipseInRect (Bounds);
context.SetFillColor (ClockColor);
context.FillPath ();
}
示例4: 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();
}
示例5: DrawLayer
public override void DrawLayer(CALayer layer, CGContext context)
{
context.SaveState ();
context.SetFillColor (1.0f, 1.0f, 1.0f, 1.0f);
context.FillRect (context.GetClipBoundingBox ());
context.TranslateCTM (0.0f, layer.Bounds.Size.Height);
context.ScaleCTM (1.0f, -1.0f);
context.ConcatCTM (this.oParentController.currentPDFPage.GetDrawingTransform (CGPDFBox.Crop, layer.Bounds, 0, true));
context.DrawPDFPage (this.oParentController.currentPDFPage);
context.RestoreState ();
}
示例6: DrawStars
protected void DrawStars (CGContext context)
{
// HACK: Change SetRGBColor to SetFillColor
context.SetFillColor (1f, 0f, 0f, 1f);
// save state so that as we translate (move the origin around,
// it goes back to normal when we restore)
context.SetFillColor (0f, 0f, 0.329f, 1.0f);
context.SaveState ();
context.TranslateCTM (30, 300);
DrawStar (context, 30);
context.RestoreState ();
context.SetFillColor (1f, 0f, 0f, 1f);
context.SaveState ();
context.TranslateCTM (120, 200);
DrawStar (context, 30);
context.RestoreState ();
}
示例7: DrawInContext
public override void DrawInContext(CGContext ctx)
{
base.DrawInContext (ctx);
// clip
var cornerRadius = Bounds.Height / 2.0f;
UIBezierPath switchOutline = UIBezierPath.FromRoundedRect( (CGRect)Bounds, (nfloat)cornerRadius);
ctx.AddPath (switchOutline.CGPath);
ctx.Clip ();
// 1) fill the track
ctx.SetFillColor (UIColor.Green.CGColor);
ctx.AddPath(switchOutline.CGPath);
ctx.FillPath ();
// 2) fill the highlighed range //Skipped for demo
// 3) add a highlight over the track
CGRect highlight = new CGRect(cornerRadius/2, Bounds.Height/2,
Bounds.Width - cornerRadius, Bounds.Height/2);
UIBezierPath highlightPath = UIBezierPath.FromRoundedRect ((CGRect)highlight, (nfloat)highlight.Height / 2.0f);
ctx.AddPath(highlightPath.CGPath);
ctx.SetFillColor( UIColor.FromWhiteAlpha((nfloat)1.0f, (nfloat)0.4f).CGColor);
ctx.FillPath ();
// 4) inner shadow
ctx.SetShadow( new CGSize(0f, 2.0f), 3.0f, UIColor.Gray.CGColor);
ctx.AddPath (switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Gray.CGColor);
ctx.StrokePath ();
// 5) outline the track
ctx.AddPath( switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Black.CGColor);
ctx.SetLineWidth ((nfloat)0.5f);
ctx.StrokePath ();
//
// ctx.SetFillColor (UIColor.Blue.CGColor);
// ctx.FillRect (Bounds);
}
示例8: DrawInContext
public override void DrawInContext(CGContext ctx)
{
base.DrawInContext (ctx);
// clip
var cornerRadius = Bounds.Height * Slider.Curvaceousness / 2.0f;
UIBezierPath switchOutline = UIBezierPath.FromRoundedRect( (CGRect)Bounds, (nfloat)cornerRadius);
ctx.AddPath (switchOutline.CGPath);
ctx.Clip ();
// 1) fill the track
ctx.SetFillColor (Slider.TrackColor.CGColor);
ctx.AddPath(switchOutline.CGPath);
ctx.FillPath ();
// 2) fill the highlighed range
ctx.SetFillColor(Slider.TrackHighlightColor.CGColor);
var lower = Slider.positionForValue (Slider.LowValue);
var higher = Slider.positionForValue(Slider.HighValue);
ctx.FillRect((CGRect)new CGRect(lower, 0, higher - lower, Bounds.Height));
// 3) add a highlight over the track
CGRect highlight = new CGRect(cornerRadius/2, Bounds.Height/2,
Bounds.Width - cornerRadius, Bounds.Height/2);
UIBezierPath highlightPath = UIBezierPath.FromRoundedRect ((CGRect)highlight, (nfloat)highlight.Height * Slider.Curvaceousness / 2.0f);
ctx.AddPath(highlightPath.CGPath);
ctx.SetFillColor( UIColor.FromWhiteAlpha((nfloat)1.0f, (nfloat)0.4f).CGColor);
ctx.FillPath ();
// 4) inner shadow
ctx.SetShadow( new CGSize(0f, 2.0f), 3.0f, UIColor.Gray.CGColor);
ctx.AddPath (switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Gray.CGColor);
ctx.StrokePath ();
// 5) outline the track
ctx.AddPath( switchOutline.CGPath);
ctx.SetStrokeColor(UIColor.Black.CGColor);
ctx.SetLineWidth ((nfloat)0.5f);
ctx.StrokePath ();
}
示例9: DrawInContext
public override void DrawInContext (CGContext ctx)
{
base.DrawInContext (ctx);
var bounds = Bounds;
var c = new PointF (bounds.GetMidX (), bounds.GetMidY ());
ctx.BeginPath ();
ctx.MoveTo (c.X, c.Y);
ctx.AddLineToPoint (bounds.Right, c.Y);
ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)Angle, false);
ctx.AddLineToPoint (c.X, c.Y);
ctx.SetFillColor (otherColor);
ctx.FillPath ();
ctx.BeginPath ();
ctx.MoveTo (c.X, c.Y);
ctx.AddLineToPoint (bounds.Right, c.Y);
ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)(1e-7 + Angle), true);
ctx.AddLineToPoint (c.X, c.Y);
ctx.SetFillColor (color);
ctx.FillPath ();
}
示例10: DrawLayer
public override void DrawLayer(CALayer layer, CGContext context)
{
// fill with white background
context.SetFillColor (1.0f, 1.0f, 1.0f, 1.0f);
context.FillRect (bounds);
context.SaveState ();
// flip page so we render it as it's meant to be read
context.TranslateCTM (0.0f, bounds.Height);
context.ScaleCTM (1.0f, -1.0f);
// scale page at the view-zoom level
context.ScaleCTM (view.Scale, view.Scale);
context.DrawPDFPage (view.Page);
context.RestoreState ();
}
示例11: DrawLayer
public override void DrawLayer (CALayer layer, CGContext context)
{
// keep a copy since (a) it's a _virtual_ property and (b) it could change between filling and flipping
RectangleF bounds = view.Bounds;
// fill with white background
context.SetFillColor (1.0f, 1.0f, 1.0f, 1.0f);
context.FillRect (bounds);
context.SaveState ();
// flip page so we render it as it's meant to be read
context.TranslateCTM (0.0f, bounds.Height);
context.ScaleCTM (1.0f, -1.0f);
// scale page at the view-zoom level
context.ScaleCTM (view.Scale, view.Scale);
context.DrawPDFPage (view.Page);
context.RestoreState ();
}
示例12: DrawInContext
public override void DrawInContext (CGContext context)
{
// Drawing with a white stroke color
context.SetStrokeColor (1, 1, 1, 1);
// And drawing with a blue fill color
context.SetFillColor (0, 0, 1, 1);
// Draw them with a 2 stroke width so they are a bit more visible.
context.SetLineWidth (2);
// Add Rect to the current path, then stroke it
context.AddRect (new CGRect (30, 30, 60, 60));
context.StrokePath ();
// Stroke Rect convenience that is equivalent to above
context.StrokeRect (new CGRect (30, 120, 60, 60));
// Stroke rect convenience equivalent to the above, plus a call to context.SetLineWidth ().
context.StrokeRectWithWidth (new CGRect (30, 210, 60, 60), 10);
// Demonstate the stroke is on both sides of the path.
context.SaveState ();
context.SetStrokeColor (1, 0, 0, 1);
context.StrokeRectWithWidth (new CGRect (30, 210, 60, 60), 2);
context.RestoreState ();
var rects = new CGRect [] {
new CGRect (120, 30, 60, 60),
new CGRect (120, 120, 60, 60),
new CGRect (120, 210, 60, 60),
};
// Bulk call to add rects to the current path.
context.AddRects (rects);
context.StrokePath ();
// Create filled rectangles via two different paths.
// Add/Fill path
context.AddRect (new CGRect (210, 30, 60, 60));
context.FillPath ();
// Fill convienience.
context.FillRect (new CGRect (210, 120, 60, 60));
}
示例13: DrawInContext
public override void DrawInContext (CGContext context)
{
var imageRect = new CGRect (8, 8, 64, 64);
// Note: The images are actually drawn upside down because Quartz image drawing expects
// the coordinate system to have the origin in the lower-left corner, but a UIView
// puts the origin in the upper-left corner. For the sake of brevity (and because
// it likely would go unnoticed for the image used) this is not addressed here.
// For the demonstration of PDF drawing however, it is addressed, as it would definately
// be noticed, and one method of addressing it is shown there.
// Draw the image in the upper left corner (0,0) with size 64x64
context.DrawImage (imageRect, image);
// Tile the same image across the bottom of the view
// CGContextDrawTiledImage() will fill the entire clipping area with the image, so to avoid
// filling the entire view, we'll clip the view to the rect below. This rect extends
// past the region of the view, but since the view's rectangle has already been applied as a clip
// to our drawing area, it will be intersected with this rect to form the final clipping area
context.ClipToRect (new CGRect (0, 80, Bounds.Width, Bounds.Height));
// The origin of the image rect works similarly to the phase parameter for SetLineDash and
// SetPatternPhase and specifies where in the coordinate system the "first" image is drawn.
// The size (previously set to 64x64) specifies the size the image is scaled to before being tiled.
imageRect.X = 32;
imageRect.Y = 112;
context.DrawTiledImage (imageRect, image);
// Highlight the "first" image from the DrawTiledImage call.
context.SetFillColor (1, 0, 0, 0.5f);
context.FillRect (imageRect);
// And stroke the clipped area
context.SetLineWidth (3);
context.SetStrokeColor (1, 0, 0, 1);
context.StrokeRect (context.GetClipBoundingBox ());
}
示例14: 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
CGRect rect = new CGRect (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);
}
示例15: 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
CGRect rect = new CGRect (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);
}