本文整理汇总了C#中CGContext.SetLineJoin方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetLineJoin方法的具体用法?C# CGContext.SetLineJoin怎么用?C# CGContext.SetLineJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.SetLineJoin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawInContext
public override void DrawInContext (CGContext context)
{
// Drawing lines with a white stroke color
context.SetRGBStrokeColor(1, 1, 1, 1);
// Preserve the current drawing state
context.SaveState();
// Set the line width so that the cap is visible
context.SetLineWidth(20);
// Line caps demonstration
// Line cap butt, default.
context.SetLineCap(CGLineCap.Butt);
context.MoveTo(40, 30);
context.AddLineToPoint(280, 30);
context.StrokePath();
// Line cap round
context.SetLineCap(CGLineCap.Round);
context.MoveTo(40, 65);
context.AddLineToPoint(280, 65);
context.StrokePath();
// Line cap square
context.SetLineCap(CGLineCap.Square);
context.MoveTo(40, 100);
context.AddLineToPoint(280, 100);
context.StrokePath();
// Restore the previous drawing state, and save it again.
context.RestoreState();
context.SaveState();
// Set the line width so that the join is visible
context.SetLineWidth(20);
// Line join miter, default
context.SetLineJoin(CGLineJoin.Miter);
context.MoveTo(40, 260);
context.AddLineToPoint(160, 140);
context.AddLineToPoint(280, 260);
context.StrokePath();
// Line join round
context.SetLineJoin(CGLineJoin.Round);
context.MoveTo(40, 320);
context.AddLineToPoint(160, 200);
context.AddLineToPoint(280, 320);
context.StrokePath();
// Line join bevel
context.SetLineJoin(CGLineJoin.Bevel);
context.MoveTo(40, 380);
context.AddLineToPoint(160, 260);
context.AddLineToPoint(280, 380);
context.StrokePath();
// Restore the previous drawing state.
context.RestoreState();
// Demonstrate where the path that generated each line is
context.SetRGBStrokeColor(1, 0, 0, 1);
context.SetLineWidth(3);
context.MoveTo(40, 30);
context.AddLineToPoint(280, 30);
context.MoveTo(40, 65);
context.AddLineToPoint(280, 65);
context.MoveTo(40, 100);
context.AddLineToPoint(280, 100);
context.MoveTo(40, 260);
context.AddLineToPoint(160, 140);
context.AddLineToPoint(280, 260);
context.MoveTo(40, 320);
context.AddLineToPoint(160, 200);
context.AddLineToPoint(280, 320);
context.MoveTo(40, 380);
context.AddLineToPoint(160, 260);
context.AddLineToPoint(280, 380);
context.StrokePath();
}
示例2: DrawRoundedLine
public static void DrawRoundedLine(CGContext context, List<PointF> points, CGColor color, float lineWidth, bool closePath, bool dashed)
{
if (points == null)
throw new NullReferenceException();
if (points.Count == 0)
throw new ArgumentException("The line must have at least one point.");
context.SaveState();
context.SetStrokeColor(color);
context.SetLineWidth(lineWidth);
context.SetLineCap(CGLineCap.Round);
context.SetLineJoin(CGLineJoin.Round);
context.MoveTo(points[0].X, points[0].Y);
for(int a = 1; a < points.Count; a++)
context.AddLineToPoint(points[a].X, points[a].Y);
if (dashed)
context.SetLineDash(0, new float[2] { 1, 2 }, 2);
if (closePath)
context.ClosePath();
context.StrokePath();
context.RestoreState();
}
示例3: DrawRectangle
private void DrawRectangle(CGContext g, PinboardData.RectangleInfo rectInfo)
{
g.SetFillColor(rectInfo.Color);
g.FillRect(rectInfo.Rectangle);
float pw = 0.5f;
CGColor rectBorderColor = new CGColor(0f, rectInfo.Color.Alpha);
g.SetLineWidth(pw);
g.SetStrokeColor(rectBorderColor);
g.SetFillColor(rectInfo.Color);
g.SetLineJoin(CGLineJoin.Miter);
g.BeginPath();
g.StrokeRect(rectInfo.Rectangle);
int margin = 5;
// TODO: Make the font configurable
NSFont font = NSFont.FromFontName("Helvetica", 12f);
NSObject[] objects = new NSObject[] { font, (NSNumber)0 };
NSObject[] keys = new NSObject[] { NSAttributedString.FontAttributeName, NSAttributedString.LigatureAttributeName };
NSDictionary attributes = NSDictionary.FromObjectsAndKeys(objects, keys);
NSAttributedString attrString = new NSAttributedString(rectInfo.Name, attributes);
attrString.DrawString(new RectangleF(rectInfo.X + margin, rectInfo.Y + margin, rectInfo.Width - 2 * margin, rectInfo.Height - 2 * margin));
}
示例4: DrawPoints
//does the actual coloring
void DrawPoints(CGContext dctx)
{
var swatches = Swatches;
var swatchslider = swatchSlider;
dctx.BeginPath ();
dctx.MoveTo (Points.First().X, Points.First().Y);
dctx.SetLineWidth (swatchslider.Value);
dctx.SetBlendMode (CGBlendMode.Normal);
foreach (var crayon in Crayons) {
if(crayon.Selected) {
if (crayon.Name == "Eraser") {
dctx.SetBlendMode (CGBlendMode.Clear);
dctx.SetStrokeColor (UIColor.Clear.CGColor);
} else {
dctx.SetBlendMode (CGBlendMode.Normal);
var swatchImg = colorSwatch (swatches[0], crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 1f);
UIColor pattern = UIColor.FromPatternImage(swatchImg);
dctx.SetStrokeColor(pattern.CGColor);
}
dctx.SetLineCap (CGLineCap.Round);
dctx.SetLineJoin (CGLineJoin.Round);
}
}
//set fill color with current crayons
foreach (var point in Points) {
dctx.AddLineToPoint(point.X, point.Y);
}
dctx.StrokePath();
}