本文整理汇总了C#中MonoMac.CoreGraphics.CGContext.SetLineWidth方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.SetLineWidth方法的具体用法?C# CGContext.SetLineWidth怎么用?C# CGContext.SetLineWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.CoreGraphics.CGContext
的用法示例。
在下文中一共展示了CGContext.SetLineWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawEllipsis
public static void DrawEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
{
context.SaveState();
context.SetStrokeColor(color);
context.SetLineWidth(lineWidth);
context.AddEllipseInRect(rect);
context.StrokePath();
context.RestoreState();
}
示例2: DrawRect
public static void DrawRect(CGContext context, RectangleF rect, CGColor color, float lineWidth)
{
context.SaveState();
context.AddRect(rect);
context.Clip();
context.SetLineWidth(lineWidth);
context.SetStrokeColor(color);
context.StrokeRect(rect);
context.RestoreState();
}
示例3: DrawLine
public static void DrawLine(CGContext context, PointF[] points, float lineWidth, CGColor color)
{
context.SaveState();
var path = new CGPath();
path.AddLines(points);
context.AddPath(path);
context.SetLineWidth(lineWidth);
context.SetStrokeColor(color);
context.StrokePath();
context.RestoreState();
}
示例4: 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);
}
示例5: 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);
}
示例6: HatchDiagonalCross
void HatchDiagonalCross(CGContext context)
{
var hatchWidth = getHatchWidth (hatchStyle);
var hatchHeight = getHatchHeight (hatchStyle);
var lineWidth = getLineWidth (hatchStyle);
initializeContext(context, hatchHeight, true);
/* draw background */
drawBackground (context, backColor, hatchWidth, hatchHeight);
/* draw lines in the foreground color */
context.SetStrokeColor(foreColor.ToCGColor());
context.SetLineWidth(lineWidth);
context.SetLineCap(CGLineCap.Square);
float halfMe = hatchHeight / 2.0f;
context.MoveTo(0, 0);
context.AddLineToPoint(hatchWidth, hatchHeight);
context.StrokePath();
context.MoveTo(hatchWidth, 0);
context.AddLineToPoint(0, hatchHeight);
context.StrokePath();
}
示例7: HatchDiagonalBrick
void HatchDiagonalBrick(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.SetStrokeColor(foreColor.ToCGColor());
context.SetLineWidth(lineWidth);
context.SetLineCap(CGLineCap.Square);
hatchHeight -= 1;
hatchWidth -= 1;
context.MoveTo(0, 0);
context.AddLineToPoint(hatchWidth,hatchHeight);
context.StrokePath();
context.MoveTo(0, hatchHeight);
context.AddLineToPoint(hatchWidth / 2.0f,hatchHeight / 2.0f);
context.StrokePath();
}
示例8: HatchOutlinedDiamond
void HatchOutlinedDiamond(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);
// this is really just two diagonal lines from each corner too
// their opposite corners.
context.MoveTo(0,0);
context.AddLineToPoint(hatchWidth, hatchHeight);
context.StrokePath();
context.MoveTo(1,hatchHeight);
context.AddLineToPoint(hatchWidth, 1);
context.StrokePath();
}
示例9: HatchUpwardDiagonal
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();
}
}
示例10: 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);
//.........这里部分代码省略.........
示例11: HatchGrid
protected void HatchGrid(CGContext context)
{
var hatchSize = getHatchWidth (hatchStyle);
var lineWidth = getLineWidth (hatchStyle);
initializeContext(context, hatchSize, false);
/* draw background */
drawBackground (context, backColor, hatchSize, hatchSize);
/* draw lines in the foreground color */
context.SetStrokeColor(foreColor.ToCGColor());
context.SetLineWidth(lineWidth);
context.SetLineCap(CGLineCap.Square);
hatchSize -=HALF_PIXEL_X;
float yoffset = 0;
if (hatchStyle == HatchStyle.DottedGrid)
{
yoffset = 1;
float[] dash = new float[] { 1, 1};
context.SetLineDash(2,dash);
}
/* draw a horizontal line */
context.MoveTo(0,yoffset);
context.AddLineToPoint(0,hatchSize);
context.StrokePath();
/* draw a vertical line */
context.MoveTo(0,hatchSize);
context.AddLineToPoint(hatchSize, hatchSize);
context.StrokePath();
}
示例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();
}
示例13: 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();
}
示例14: HatchShingle
void HatchShingle(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 are basically going to draw a lamda sign
// Draw base
context.MoveTo(0,0);
context.AddLineToPoint(halfMe,halfMe-HALF_PIXEL_Y);
context.AddLineToPoint(hatchWidth, HALF_PIXEL_Y);
context.StrokePath();
// draw the first part of tail
context.MoveTo(halfMe + HALF_PIXEL_X, halfMe);
context.AddLineToPoint(halfMe + HALF_PIXEL_X, halfMe + 1);
context.StrokePath();
// now the last curl on the tail
RectangleF rect = new RectangleF(1,hatchHeight-1,1,1);
setPixels(context, rect);
rect.X += 1;
setPixels(context, rect);
rect.X += 1;
rect.Y -= 1;
setPixels(context, rect);
}
示例15: 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);
}