本文整理汇总了C#中Android.Graphics.Path类的典型用法代码示例。如果您正苦于以下问题:C# Path类的具体用法?C# Path怎么用?C# Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于Android.Graphics命名空间,在下文中一共展示了Path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:rfcclub,项目名称:dot42,代码行数:25,代码来源:ShapeView.cs
示例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();
}
}
开发者ID:Coolerhino,项目名称:MvvmCross-Tutorials,代码行数:27,代码来源:ShapeView.cs
示例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);
}
开发者ID:adolfo7x,项目名称:Play.Stopwatch,代码行数:27,代码来源:StopwatchView.cs
示例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();
}
}
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:29,代码来源:CustomDrawShapeView.cs
示例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;
}
开发者ID:ehill8624,项目名称:ValkreRender,代码行数:25,代码来源:DrawingImageView.cs
示例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);
}
开发者ID:colbylwilliams,项目名称:BasicBeer-Forms,代码行数:34,代码来源:CircleImage.cs
示例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);
}
开发者ID:elviosousa,项目名称:Xamarin.Plugins,代码行数:66,代码来源:ImageCircleRenderer.cs
示例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;
}
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:12,代码来源:CanvasRenderContext.cs
示例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);
}
开发者ID:onikiri2007,项目名称:TestApp,代码行数:58,代码来源:CircleImageRenderer.cs
示例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;
}
开发者ID:Appercode,项目名称:monodroid-samples,代码行数:9,代码来源:SvgHelper.cs
示例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;
}
开发者ID:jdluzen,项目名称:xamsvg,代码行数:10,代码来源:SVGPolylineParser.cs
示例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();
}
开发者ID:Cheesebaron,项目名称:MonoDroid.PathFillTypes,代码行数:10,代码来源:PathFillSampleView.cs
示例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();
}
开发者ID:adolfo7x,项目名称:Play.Stopwatch,代码行数:12,代码来源:StopwatchView.cs
示例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;
}
开发者ID:frankcalise,项目名称:XamDroid.FitChart,代码行数:12,代码来源:OverdrawValueRenderer.cs
示例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;
}
开发者ID:frankcalise,项目名称:XamDroid.FitChart,代码行数:12,代码来源:LinearValueRenderer.cs
示例16: Initialize
void Initialize()
{
drawPath = new Path();
drawPaint = new Paint();
drawPaint.Color = Color.Black;
drawPaint.AntiAlias=true;
drawPaint.StrokeWidth =20;
drawPaint.SetStyle(Paint.Style.Stroke);
drawPaint.StrokeJoin = Paint.Join.Round;
drawPaint.StrokeCap = Paint.Cap.Round;
canvasPaint = new Paint(PaintFlags.Dither);
DrawingCacheEnabled = true;
}
开发者ID:CrossGeeks,项目名称:Xamarin.Samples,代码行数:13,代码来源:NativeDrawView.cs
示例17: DrawChild
/// <summary>
/// Redraws the child.
/// </summary>
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var radius = (float)((RoundedImage)Element).BorderRadius;
var stroke = (float)((RoundedImage)Element).BorderThickness;
var delta = (float)stroke / 2.0f;
if (radius < 0)
{
radius = Math.Min(Width, Height) / 2.0f;
}
radius -= delta;
// Clip with rounded rect
var path = new Path();
path.AddRoundRect(new RectF(delta, delta, Width - stroke, Height - stroke),
radius, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
path.Dispose();
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
// Add stroke for smoother border
path = new Path();
path.AddRoundRect(new RectF(delta, delta, Width - stroke, Height - stroke),
radius, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = stroke;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = ((RoundedImage)Element).BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
// Clean up
path.Dispose();
return result;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
开发者ID:TheUniforms,项目名称:Forms-Images,代码行数:54,代码来源:RoundedImageRenderer.cs
示例18: Draw
/// <Docs>The Canvas to which the View is rendered.</Docs>
/// <summary>
/// Draw the specified canvas.
/// </summary>
/// <param name="canvas">Canvas.</param>
public override void Draw (Canvas canvas)
{
try
{
var element = Element as RoundCornerView;
var cornerRadius = (float)element.CornerRadius*Resources.DisplayMetrics.Density;
// Paint rounded rect itself
canvas.Save();
var paint = new Paint();
paint.AntiAlias = true;
var strokeWidth = (((float)element.BorderWidth)*Resources.DisplayMetrics.Density);
paint.StrokeWidth = strokeWidth;
if(element.BackgroundColor != Xamarin.Forms.Color.Transparent)
{
paint.SetStyle(Paint.Style.Fill);
paint.Color = element.BackgroundColor.ToAndroid();
canvas.DrawRoundRect(new RectF(0, 0, Width, Height), cornerRadius, cornerRadius, paint);
}
if(element.BorderColor != Xamarin.Forms.Color.Transparent)
{
paint.SetStyle(Paint.Style.Stroke);
paint.Color = element.BorderColor.ToAndroid();
canvas.DrawRoundRect(new RectF(0, 0, Width, Height), cornerRadius, cornerRadius, paint);
}
//Properly dispose
paint.Dispose();
canvas.Restore();
// Create clip path
var path = new Path();
path.AddRoundRect(new RectF(0.0f + (strokeWidth/2), 0.0f + (strokeWidth/2),
Width - (strokeWidth/2), Height - (strokeWidth/2)), cornerRadius, cornerRadius, Path.Direction.Cw);
canvas.Save();
canvas.ClipPath(path);
// Do base drawing
for(var i=0; i<ChildCount; i++)
GetChildAt(i).Draw(canvas);
canvas.Restore();
path.Dispose();
}
catch (Exception)
{
}
}
开发者ID:patridge,项目名称:NControl.Controls,代码行数:56,代码来源:RoundCornerViewRenderer.cs
示例19: CreateAnimationDrawer
public CreateAnimationDrawer(Context c, BrushItem brush, Canvas canvas, Bitmap myBmp, bool tooAdd = false, int cell = 1, string DrawerState = "brush_selection", Path pathToUse = null)
: base(c)
{
myBitmap = myBmp;
myCanvas = canvas;
DrawerStateInternal = DrawerState;
addOnly = tooAdd;
status = 0;
myPath = new Path();
myPaint = new Paint(PaintFlags.Dither);
myPaint.AntiAlias = true;
myPaint.Dither = true;
myPaint.SetStyle(Paint.Style.Stroke);
myPaint.StrokeJoin = Paint.Join.Round;
myPaint.StrokeWidth = brush.Thickness;
myPaint.StrokeCap = Paint.Cap.Round;
myPaint.SetARGB(colorUtil.a, colorUtil.r, colorUtil.g, colorUtil.b);
if (brush.BrushType == AnimationTypesBrushType.Spray)
myPaint.SetShadowLayer(brush.Thickness, 0, 0, ImageHelper.convWZColorToColor(brush.BrushColor));
if (DrawerState == "brush_selection")
{
if (pathToUse != null)
{
myBoundsPaint = new Paint();
myBoundsPaint = new Paint(PaintFlags.Dither);
myBoundsPaint.AntiAlias = true;
myBoundsPaint.Dither = true;
myBoundsPaint.SetStyle(Paint.Style.Stroke);
myBoundsPaint.StrokeJoin = Paint.Join.Round;
myBoundsPaint.StrokeWidth = 10f;
myBoundsPaint.StrokeCap = Paint.Cap.Round;
myBoundsPaint.SetARGB(255, 0, 0, 0);
myBoundsPaint.SetPathEffect(new DashPathEffect(new float[]
{
10f,
20f
}, 0));
myPath = pathToUse;
AnimationUtil.theCanvas.DrawPath(myPath, myPaint);
AnimationUtil.theCanvas.DrawPath(myPath, myPaint);
myBoundsRect = new RectF();
myPath.ComputeBounds(myBoundsRect, true);
AnimationUtil.theCanvas.DrawRect(myBoundsRect, myBoundsPaint);
}
}
}
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:50,代码来源:CreateAnimationDrawer.cs
示例20: Draw
/// <Docs>The Canvas to which the View is rendered.</Docs>
/// <summary>
/// BoxViewのカスタマイズはDrawで行う
/// </summary>
/// <param name="canvas">Canvas.</param>
public override void Draw(Android.Graphics.Canvas canvas)
{
// 2重に描画してしまうので、baseは描画しない
//base.Draw(canvas);
// ElementをキャストしてFormsで定義したCustomBoxViewを取得
var formsBox = (CustomBoxView)Element;
// Androidの描画はPaintを使用
using (var paint = new Paint())
{
// 塗りつぶし色の設定
paint.Color = formsBox.FillColor.ToAndroid();
// 吹き出し部分の設定
// パスの生成
var path = new Path();
// スタート地点の設定
path.MoveTo(0, 0);
// 経由地点の設定
path.LineTo(100, 10);
path.LineTo(100, 100);
// パスを繋げる
path.Close();
// 描画
canvas.DrawPath(path, paint);
// 角の丸い四角の設定
// 角丸の直径を決める
// widthとheightを比較して小さい方を基準にする
var minSize = Math.Min(Width, Height);
// 指定するのは直径なので、指定半径を2倍する
var diameter = formsBox.Radius * 2;
// 角丸の直径はminSize以下でなければならない
if (diameter > minSize)
diameter = minSize;
// 描画領域の設定
var rect = new RectF(0, 0, (float)Width, (float)Height);
//四角形描画
canvas.DrawRoundRect(rect, diameter, diameter, paint);
}
}
开发者ID:mattsuDev,项目名称:Xamarin.Forms.CustomBox,代码行数:55,代码来源:CustomBoxViewRenderer.cs
注:本文中的Android.Graphics.Path类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论