本文整理汇总了C#中Android.Graphics.Path.QuadTo方法的典型用法代码示例。如果您正苦于以下问题:C# Path.QuadTo方法的具体用法?C# Path.QuadTo怎么用?C# Path.QuadTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Path
的用法示例。
在下文中一共展示了Path.QuadTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareAnimation
ObjectAnimator PrepareAnimation(View view, int multiplier)
{
var path = new Path();
var metrics = Resources.DisplayMetrics;
var tx = multiplier * (metrics.WidthPixels - view.PaddingRight);
var ty = -TypedValue.ApplyDimension(ComplexUnitType.Dip, 64, metrics);
path.MoveTo(tx, ty);
path.QuadTo(2 * tx / 3, 0, 0, 0);
view.TranslationX = tx;
view.TranslationY = ty;
var anim = ObjectAnimator.OfFloat(view, "translationX", "translationY", path);
anim.SetDuration(600);
anim.SetInterpolator(AnimationUtils.LoadInterpolator(this, Android.Resource.Interpolator.FastOutSlowIn));
return anim;
}
示例2: ToTransformedCorners
public static Bitmap ToTransformedCorners(Bitmap source, double topLeftCornerSize, double topRightCornerSize, double bottomLeftCornerSize, double bottomRightCornerSize,
CornerTransformType cornersTransformType, double cropWidthRatio, double cropHeightRatio)
{
double sourceWidth = source.Width;
double sourceHeight = source.Height;
double desiredWidth = sourceWidth;
double desiredHeight = sourceHeight;
double desiredRatio = cropWidthRatio / cropHeightRatio;
double currentRatio = sourceWidth / sourceHeight;
if (currentRatio > desiredRatio)
{
desiredWidth = (cropWidthRatio * sourceHeight / cropHeightRatio);
}
else if (currentRatio < desiredRatio)
{
desiredHeight = (cropHeightRatio * sourceWidth / cropWidthRatio);
}
topLeftCornerSize = topLeftCornerSize * (desiredWidth + desiredHeight) / 2 / 100;
topRightCornerSize = topRightCornerSize * (desiredWidth + desiredHeight) / 2 / 100;
bottomLeftCornerSize = bottomLeftCornerSize * (desiredWidth + desiredHeight) / 2 / 100;
bottomRightCornerSize = bottomRightCornerSize * (desiredWidth + desiredHeight) / 2 / 100;
float cropX = (float)((sourceWidth - desiredWidth) / 2);
float cropY = (float)((sourceHeight - desiredHeight) / 2);
Bitmap bitmap = Bitmap.CreateBitmap((int)desiredWidth, (int)desiredHeight, Bitmap.Config.Argb8888);
using (Canvas canvas = new Canvas(bitmap))
using (Paint paint = new Paint())
using (BitmapShader shader = new BitmapShader(source, Shader.TileMode.Clamp, Shader.TileMode.Clamp))
using (Matrix matrix = new Matrix())
using (var path = new Path())
{
if (cropX != 0 || cropY != 0)
{
matrix.SetTranslate(-cropX, -cropY);
shader.SetLocalMatrix(matrix);
}
paint.SetShader(shader);
paint.AntiAlias = true;
// TopLeft
if (cornersTransformType.HasFlag(CornerTransformType.TopLeftCut))
{
path.MoveTo(0, (float)topLeftCornerSize);
path.LineTo((float)topLeftCornerSize, 0);
}
else if (cornersTransformType.HasFlag(CornerTransformType.TopLeftRounded))
{
path.MoveTo(0, (float)topLeftCornerSize);
path.QuadTo(0, 0, (float)topLeftCornerSize, 0);
}
else
{
path.MoveTo(0, 0);
}
// TopRight
if (cornersTransformType.HasFlag(CornerTransformType.TopRightCut))
{
path.LineTo((float)(desiredWidth - topRightCornerSize), 0);
path.LineTo((float)desiredWidth, (float)topRightCornerSize);
}
else if (cornersTransformType.HasFlag(CornerTransformType.TopRightRounded))
{
path.LineTo((float)(desiredWidth - topRightCornerSize), 0);
path.QuadTo((float)desiredWidth, 0, (float)desiredWidth, (float)topRightCornerSize);
}
else
{
path.LineTo((float)desiredWidth ,0);
}
// BottomRight
if (cornersTransformType.HasFlag(CornerTransformType.BottomRightCut))
{
path.LineTo((float)desiredWidth, (float)(desiredHeight - bottomRightCornerSize));
path.LineTo((float)(desiredWidth - bottomRightCornerSize), (float)desiredHeight);
}
else if (cornersTransformType.HasFlag(CornerTransformType.BottomRightRounded))
{
path.LineTo((float)desiredWidth, (float)(desiredHeight - bottomRightCornerSize));
path.QuadTo((float)desiredWidth, (float)desiredHeight, (float)(desiredWidth - bottomRightCornerSize), (float)desiredHeight);
}
else
{
path.LineTo((float)desiredWidth, (float)desiredHeight);
}
// BottomLeft
if (cornersTransformType.HasFlag(CornerTransformType.BottomLeftCut))
{
path.LineTo((float)bottomLeftCornerSize, (float)desiredHeight);
path.LineTo(0, (float)(desiredHeight - bottomLeftCornerSize));
}
//.........这里部分代码省略.........
示例3: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
switch(mShape)
{
case Shape.TRIANGLE:
{
if (mIsLoading)
{
mAnimPercent += 0.1611113f;
Path path = new Path();
path.MoveTo(RelativeXFromView(0.5f),
RelativeYFromView(0.5f));
if (mAnimPercent >= 1)
{
mShape = Shape.CIRCLE;
mIsLoading = false;
mAnimPercent = 1;
}
float controlX = mControlX - RelativeXFromView(mAnimPercent * triangle2Circle) * genhao3;
float controlY = mControlY - RelativeYFromView(mAnimPercent * triangle2Circle);
path.QuadTo(RelativeXFromView(1) - controlX, controlY, RelativeXFromView(0.5f + genhao3 / 4),
RelativeYFromView(0.75f));
path.QuadTo(RelativeXFromView(0.5f), RelativeYFromView(0.75f + 2 * mAnimPercent * triangle2Circle),
RelativeXFromView(0.5f - genhao3 / 4), RelativeYFromView(0.75f));
path.QuadTo(controlX, controlY, RelativeXFromView(0.5f), RelativeYFromView(0f));
path.Close();
canvas.DrawPath(path, mPaint);
Invalidate();
}
else
{
Path path = new Path();
mPaint.Color = Resources.GetColor(Resource.Color.triangle);
path.MoveTo(RelativeXFromView(0.5f), RelativeYFromView(0f));
path.LineTo(RelativeXFromView(1), RelativeYFromView(genhao3 / 2f));
path.LineTo(RelativeXFromView(0), RelativeYFromView(genhao3 / 2f));
mControlX = RelativeXFromView(0.5f - genhao3 / 8f);
mControlY = RelativeYFromView(3 / 8f);
mAnimPercent = 0;
path.Close();
canvas.DrawPath(path, mPaint);
}
}
break;
case Shape.CIRCLE:
{
if(mIsLoading)
{
float magicNumber = mMagicNumber + mAnimPercent;
mAnimPercent += 0.12f;
if(magicNumber + mAnimPercent > 1.9f)
{
mShape = Shape.RECT;
mIsLoading = false;
}
Path path = new Path();
path.MoveTo(RelativeXFromView(0.5f), RelativeYFromView(0f));
path.CubicTo(RelativeXFromView(0.5f + magicNumber / 2), RelativeYFromView(0f),
RelativeXFromView(1), RelativeYFromView(0.5f - magicNumber / 2),
RelativeXFromView(1f), RelativeYFromView(0.5f));
path.CubicTo(RelativeXFromView(1), RelativeXFromView(0.5f + magicNumber / 2),
RelativeXFromView(0.5f + mMagicNumber / 2), RelativeYFromView(1f),
RelativeXFromView(0.5f), RelativeYFromView(1f));
path.CubicTo(RelativeXFromView(0.5f - magicNumber / 2), RelativeXFromView(1f),
RelativeXFromView(0), RelativeYFromView(0.5f + magicNumber / 2),
RelativeXFromView(0f), RelativeYFromView(0.5f));
path.CubicTo(RelativeXFromView(0f), RelativeXFromView(0.5f - magicNumber / 2),
RelativeXFromView(0.5f - magicNumber / 2), RelativeYFromView(0),
RelativeXFromView(0.5f), RelativeYFromView(0f));
path.Close();
canvas.DrawPath(path, mPaint);
Invalidate();
}
else
{
mPaint.Color = Resources.GetColor(Resource.Color.circle);
Path path = new Path();
float magicNumber = mMagicNumber;
path.MoveTo(RelativeXFromView(0.5f), RelativeYFromView(0f));
path.CubicTo(RelativeXFromView(0.5f + magicNumber / 2), 0,
RelativeXFromView(1), RelativeYFromView(magicNumber / 2),
RelativeXFromView(1f), RelativeYFromView(0.5f));
path.CubicTo(
RelativeXFromView(1), RelativeXFromView(0.5f + magicNumber / 2),
RelativeXFromView(0.5f + magicNumber / 2), RelativeYFromView(1f),
RelativeXFromView(0.5f), RelativeYFromView(1f));
path.CubicTo(RelativeXFromView(0.5f - magicNumber / 2), RelativeXFromView(1f),
RelativeXFromView(0), RelativeYFromView(0.5f + magicNumber / 2),
RelativeXFromView(0f), RelativeYFromView(0.5f));
path.CubicTo(RelativeXFromView(0f), RelativeXFromView(0.5f - magicNumber / 2),
RelativeXFromView(0.5f - magicNumber / 2), RelativeYFromView(0),
RelativeXFromView(0.5f), RelativeYFromView(0f));
mAnimPercent = 0;
path.Close();
canvas.DrawPath(path, mPaint);
}
}
//.........这里部分代码省略.........