本文整理汇总了C#中Android.Graphics.Path类的典型用法代码示例。如果您正苦于以下问题:C# Path类的具体用法?C# Path怎么用?C# Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于Android.Graphics命名空间,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawShape
protected void DrawShape(Canvas canvas)
{
Paint paint = new Paint();
paint.Color = Color;
switch (Shape)
{
case ShapeEnum.RectangleShape:
canvas.DrawRect(0, 0, ShapeWidth, ShapeHeight, paint);
break;
case ShapeEnum.OvalShape:
canvas.DrawOval(new RectF(0, 0, ShapeWidth, ShapeHeight), paint);
break;
case ShapeEnum.TriangleShape:
Path path = new Path();
path.MoveTo(ShapeWidth / 2, 0);
path.LineTo(ShapeWidth, ShapeHeight);
path.LineTo(0,ShapeHeight);
path.Close();
canvas.DrawPath(path, paint);
break;
default:
canvas.DrawCircle(ShapeWidth / 2, ShapeHeight / 2, ShapeWidth / 2, paint);
break;
}
}
示例2: OnDraw
protected override void OnDraw(Android.Graphics.Canvas canvas)
{
var rect = new RectF(0, 0, 300, 300);
switch (Shape)
{
case Shape.Circle:
canvas.DrawOval(rect, new Paint() { Color = Color.CornflowerBlue });
break;
case Shape.Square:
canvas.DrawRect(rect, new Paint() { Color = Color.Crimson });
break;
case Shape.Triangle:
var path = new Path();
path.MoveTo(rect.CenterX(), rect.Top);
path.LineTo(rect.Left, rect.Bottom);
path.LineTo(rect.Right, rect.Bottom);
path.Close();
var paint = new Paint() {Color = Color.Crimson};
paint.Color = Color.Gold;
paint.SetStyle(Paint.Style.Fill);
canvas.DrawPath(path, paint);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
示例3: DrawStopwatch
public void DrawStopwatch(Canvas canvas)
{
canvas.Save();
canvas.Translate(Width / 2F, Height / 2F);
var tickMarks = new Path();
tickMarks.AddCircle(0, 0, 90, Path.Direction.Cw);
var scale = Math.Min(Width, Height) / 2F / 120;
canvas.Scale(scale, scale);
var paint = new Paint
{
StrokeCap = Paint.Cap.Square,
Color = new Color(240, 240, 240)
};
paint.SetStyle(Paint.Style.Stroke);
paint.StrokeWidth = 3;
paint.SetPathEffect(MinuteDashEffect);
canvas.DrawPath(tickMarks, paint);
paint.Color = new Color(240, 240, 240);
paint.StrokeWidth = 4;
paint.SetPathEffect(FifthMinuteDashEffect);
canvas.DrawPath(tickMarks, paint);
}
示例4: Draw
public override void Draw(Android.Graphics.Canvas canvas)
{
base.Draw(canvas);
var rect = new RectF(0,0,300,300);
switch (TheShape)
{
case Shape.Circle:
canvas.DrawOval(rect, new Paint() { Color = Color.Aqua });
break;
case Shape.Square:
canvas.DrawRect(rect, new Paint() { Color = Color.Red });
break;
case Shape.Triangle:
var path = new Path();
path.MoveTo(rect.CenterX(), 0);
path.LineTo(0, rect.Height());
path.LineTo(rect.Width(), rect.Height());
path.Close();
var paint = new Paint() {Color = Color.Magenta};
paint.SetStyle(Paint.Style.Fill);
canvas.DrawPath(path, paint);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
示例5: DrawingImageView
public DrawingImageView(Context context, Fragment fragment): base(context) {
mPaint = new Paint();
mPaint.AntiAlias = true;
mPaint.Dither = true;
mPaint.Color = Color.Yellow;
mPaint.SetStyle (Paint.Style.Stroke);
mPaint.StrokeJoin = Paint.Join.Round;
mPaint.StrokeCap = Paint.Cap.Round;
mPaint.StrokeWidth = 10;
cPaint = new Paint ();
cPaint.Color = Color.Yellow;
cPaint.StrokeJoin = Paint.Join.Round;
cPaint.StrokeCap = Paint.Cap.Round;
cPaint.SetTypeface(Typeface.Default);
cPaint.TextSize = 40;
mPath = new Android.Graphics.Path();
mBitmapPaint = new Paint();
mBitmapPaint.Color = Color.Yellow;
DrawingStatus = DrawingType.None;
_fragment = fragment;
}
示例6: DrawChild
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;
//Create path to clip
var path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
// Create path for circle border
path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = 5;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = global::Android.Graphics.Color.White;
canvas.DrawPath(path, paint);
//Properly dispose
paint.Dispose();
path.Dispose();
return result;
}
catch (Exception ex)
{
Console.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例7: DrawChild
/// <summary>
///
/// </summary>
/// <param name="canvas"></param>
/// <param name="child"></param>
/// <param name="drawingTime"></param>
/// <returns></returns>
protected override bool DrawChild(Canvas canvas, Android.Views.View child, long drawingTime)
{
try
{
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = ((CircleImage)Element).BorderThickness;
radius -= strokeWidth / 2;
var path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var paint = new Paint();
paint.AntiAlias = true;
paint.SetStyle(Paint.Style.Fill);
paint.Color = ((CircleImage)Element).FillColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
var thickness = ((CircleImage)Element).BorderThickness;
if(thickness > 0.0f)
{
paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = thickness;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = ((CircleImage)Element).BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
}
path.Dispose();
return result;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例8: CanvasRenderContext
/// <summary>
/// Initializes a new instance of the <see cref="CanvasRenderContext" /> class.
/// </summary>
/// <param name="scale">The scale.</param>
public CanvasRenderContext(double scale)
{
this.paint = new Paint();
this.path = new Path();
this.bounds = new Rect();
this.pts = new List<float>();
this.Scale = scale;
}
示例9: DrawChild
protected override bool DrawChild(Canvas canvas, View child, long drawingTime)
{
try
{
var radius = Math.Min(Width, Height) / 2;
var borderThickness = (float)((CircleImage)Element).BorderThickness;
int strokeWidth = 0;
if (borderThickness > 0)
{
var logicalDensity = Xamarin.Forms.Forms.Context.Resources.DisplayMetrics.Density;
strokeWidth = (int)Math.Ceiling(borderThickness * logicalDensity + .5f);
}
radius -= strokeWidth / 2;
var path = new Path();
path.AddCircle(Width / 2.0f, Height / 2.0f, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var paint = new Paint();
paint.AntiAlias = true;
paint.SetStyle(Paint.Style.Fill);
paint.Color = ((CircleImage)Element).FillColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
path = new Path();
path.AddCircle((float) Width / 2, (float) Height / 2, radius, Path.Direction.Ccw);
if (strokeWidth > 0.0f)
{
paint = new Paint {AntiAlias = true, StrokeWidth = strokeWidth};
paint.SetStyle(Paint.Style.Stroke);
paint.Color = ((CircleImage)Element).BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
}
path.Dispose();
return result;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例10: SvgPath
public SvgPath (Path path, Paint paint)
{
this.path = path;
this.paint = paint;
measure = new PathMeasure (path, false);
length = measure.Length;
region.SetPath (path, maxClip);
bounds = region.Bounds;
}
示例11: parse
internal static Path parse(float[] pPoints) {
Path path = new Path();
path.MoveTo(pPoints[0], pPoints[1]);
for (int i = 2; i < pPoints.Length; i += 2) {
float x = pPoints[i];
float y = pPoints[i + 1];
path.LineTo(x, y);
}
return path;
}
示例12: ShowPath
private void ShowPath(Canvas canvas, int x, int y, Path.FillType ft, Paint paint)
{
canvas.Save();
canvas.Translate(x, y);
canvas.ClipRect(0, 0, 120, 120);
canvas.DrawColor(Color.White);
mPath.SetFillType(ft);
canvas.DrawPath(mPath, paint);
canvas.Restore();
}
示例13: Initialize
public void Initialize()
{
_minuteHand = new Path();
_minuteHand.MoveTo(0, 10);
_minuteHand.LineTo(0, -55);
_minuteHand.Close();
_secondHand = new Path();
_secondHand.MoveTo(0, -80);
_secondHand.LineTo(0, 15);
_secondHand.Close();
}
示例14: BuildPath
public Path BuildPath (float animationProgress, float animationSeek)
{
var startAngle = FitChart.StartAngle;
var valueSweepAngle = base.Value.StartAngle + base.Value.SweepAngle;
valueSweepAngle -= startAngle;
var sweepAngle = valueSweepAngle * animationProgress;
var path = new Path ();
path.AddArc (base.DrawingArea, startAngle, sweepAngle);
return path;
}
示例15: BuildPath
public Path BuildPath (float animationProgress, float animationSeek)
{
Path path = null;
if (base.Value.StartAngle <= animationSeek)
{
path = new Path ();
var sweepAngle = CalculateSweepAngle (animationSeek, base.Value);
path.AddArc (base.DrawingArea, base.Value.StartAngle, sweepAngle);
}
return path;
}