本文整理汇总了C#中Android.Graphics.Path.CubicTo方法的典型用法代码示例。如果您正苦于以下问题:C# Path.CubicTo方法的具体用法?C# Path.CubicTo怎么用?C# Path.CubicTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Path
的用法示例。
在下文中一共展示了Path.CubicTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
void Initialize ()
{
// Create Paint for all drawing
paint = new Paint ();
// All paths are based on 100-unit clock radius
// centered at (0, 0).
// Define circle for tick marks.
tickMarks = new Path ();
tickMarks.AddCircle (0, 0, 90, Path.Direction.Cw);
// Hour, minute, second hands defined to point straight up.
// Define hour hand.
hourHand = new Path ();
hourHand.MoveTo (0, -60);
hourHand.CubicTo (0, -30, 20, -30, 5, -20);
hourHand.LineTo (5, 0);
hourHand.CubicTo (5, 7.5f, -5, 7.5f, -5, 0);
hourHand.LineTo (-5, -20);
hourHand.CubicTo (-20, -30, 0, -30, 0, -60);
hourHand.Close ();
// Define minute hand.
minuteHand = new Path ();
minuteHand.MoveTo (0, -80);
minuteHand.CubicTo (0, -75, 0, -70, 2.5f, -60);
minuteHand.LineTo (2.5f, 0);
minuteHand.CubicTo (2.5f, 5, -2.5f, 5, -2.5f, 0);
minuteHand.LineTo (-2.5f, -60);
minuteHand.CubicTo (0, -70, 0, -75, 0, -80);
minuteHand.Close ();
// Define second hand.
secondHand = new Path ();
secondHand.MoveTo (0, 10);
secondHand.LineTo (0, -80);
}
示例2: DrawPath
public void DrawPath(IEnumerable<PathOperation> ops, Pen pen = null, BaseBrush brush = null)
{
using (var path = new Path())
{
var bb = new BoundingBoxBuilder();
foreach (var op in ops)
{
var moveTo = op as MoveTo;
if (moveTo != null)
{
var start = moveTo.Start;
var end = moveTo.End;
path.MoveTo((float) start.X, (float) start.Y);
bb.Add(start);
bb.Add(end);
continue;
}
var lineTo = op as LineTo;
if (lineTo != null)
{
var start = lineTo.Start;
var end = lineTo.End;
path.LineTo((float) start.X, (float) start.Y);
path.LineTo((float) end.X, (float) end.Y);
bb.Add(start);
bb.Add(end);
continue;
}
var at = op as ArcTo;
if (at != null)
{
var p = at.Point;
path.LineTo((float) p.X, (float) p.Y);
bb.Add(p);
continue;
}
var curveTo = op as CurveTo;
if (curveTo != null)
{
var end = curveTo.End;
var firstControlPoint = curveTo.FirstControlPoint;
var secondControlPoint = curveTo.SecondControlPoint;
path.CubicTo((float) firstControlPoint.X, (float) firstControlPoint.Y, (float) secondControlPoint.X,
(float) secondControlPoint.Y, (float) end.X, (float) end.Y);
bb.Add(firstControlPoint);
bb.Add(secondControlPoint);
bb.Add(end);
continue;
}
var cp = op as ClosePath;
if (cp != null)
{
path.Close();
continue;
}
throw new NotSupportedException("Path Op " + op);
}
var frame = bb.BoundingBox;
if (brush != null)
{
var solidBrush = brush as SolidBrush;
if (solidBrush != null)
{
path.SetFillType(GetPathFillType(((SolidBrush)brush).FillMode));
}
var brushPaint = GetBrushPaint(brush, frame);
graphics.DrawPath(path, brushPaint);
}
if (pen != null)
{
var penPaint = GetPenPaint(pen);
graphics.DrawPath(path, penPaint);
}
}
}
示例3: DrawerArrowDrawable
public DrawerArrowDrawable(Resources resources, Boolean rounded1) {
rounded = rounded1;
float density = resources.DisplayMetrics.Density;
float strokeWidthPixel = STROKE_WIDTH_DP * density;
halfStrokeWidthPixel = strokeWidthPixel / 2;
linePaint = new Paint(Android.Graphics.PaintFlags.SubpixelText | Android.Graphics.PaintFlags.AntiAlias);
linePaint.StrokeCap=rounded ? Android.Graphics.Paint.Cap.Round : Android.Graphics.Paint.Cap.Butt;
linePaint.Color=Android.Graphics.Color.Black;
linePaint.SetStyle (Android.Graphics.Paint.Style.Stroke);
linePaint.StrokeWidth=strokeWidthPixel;
int dimen = (int) (DIMEN_DP * density);
bounds = new Rect(0, 0, dimen, dimen);
Path first, second;
JoinedPath joinedA, joinedB;
// Top
first = new Path();
first.MoveTo(5.042f, 20f);
first.RCubicTo(8.125f, -16.317f, 39.753f, -27.851f, 55.49f, -2.765f);
second = new Path();
second.MoveTo(60.531f, 17.235f);
second.RCubicTo(11.301f, 18.015f, -3.699f, 46.083f, -23.725f, 43.456f);
scalePath(first, density);
scalePath(second, density);
joinedA = new JoinedPath(first, second);
first = new Path();
first.MoveTo(64.959f, 20f);
first.RCubicTo(4.457f, 16.75f, 1.512f, 37.982f, -22.557f, 42.699f);
second = new Path();
second.MoveTo(42.402f, 62.699f);
second.CubicTo(18.333f, 67.418f, 8.807f, 45.646f, 8.807f, 32.823f);
scalePath(first, density);
scalePath(second, density);
joinedB = new JoinedPath(first, second);
topLine = new BridgingLine(joinedA, joinedB);
// Middle
first = new Path();
first.MoveTo(5.042f, 35f);
first.CubicTo(5.042f, 20.333f, 18.625f, 6.791f, 35f, 6.791f);
second = new Path();
second.MoveTo(35f, 6.791f);
second.RCubicTo(16.083f, 0f, 26.853f, 16.702f, 26.853f, 28.209f);
scalePath(first, density);
scalePath(second, density);
joinedA = new JoinedPath(first, second);
first = new Path();
first.MoveTo(64.959f, 35f);
first.RCubicTo(0f, 10.926f, -8.709f, 26.416f, -29.958f, 26.416f);
second = new Path();
second.MoveTo(35f, 61.416f);
second.RCubicTo(-7.5f, 0f, -23.946f, -8.211f, -23.946f, -26.416f);
scalePath(first, density);
scalePath(second, density);
joinedB = new JoinedPath(first, second);
middleLine = new BridgingLine(joinedA, joinedB);
// Bottom
first = new Path();
first.MoveTo(5.042f, 50f);
first.CubicTo(2.5f, 43.312f, 0.013f, 26.546f, 9.475f, 17.346f);
second = new Path();
second.MoveTo(9.475f, 17.346f);
second.RCubicTo(9.462f, -9.2f, 24.188f, -10.353f, 27.326f, -8.245f);
scalePath(first, density);
scalePath(second, density);
joinedA = new JoinedPath(first, second);
first = new Path();
first.MoveTo(64.959f, 50f);
first.RCubicTo(-7.021f, 10.08f, -20.584f, 19.699f, -37.361f, 12.74f);
second = new Path();
second.MoveTo(27.598f, 62.699f);
second.RCubicTo(-15.723f, -6.521f, -18.8f, -23.543f, -18.8f, -25.642f);
scalePath(first, density);
scalePath(second, density);
joinedB = new JoinedPath(first, second);
bottomLine = new BridgingLine(joinedA, joinedB);
}
示例4: Draw
public override void Draw(Canvas canvas)
{
var w = width / (Count - 2);
var path = new Path ();
path.MoveTo (0, height - u1 [0]);
for (int i = 1; i < Count; i += 3) {
path.CubicTo (i * w, height - u1 [Math.Min (Count - 1, i)],
(i + 1) * w, height - u1 [Math.Min (Count - 1, i + 1)],
(i + 2) * w, height - u1 [Math.Min (Count - 1, i + 2)]);
}
path.LineTo (width, height);
path.LineTo (0, height);
path.Close ();
canvas.DrawPath (path, paint);
if (bubblesEnabled)
DrawBubbles (canvas, w);
}
示例5: 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);
}
}
//.........这里部分代码省略.........
示例6: drawLines
void drawLines (Canvas canvas, Paint paint)
{
float x, y;
// Draw curved graph line
var whiteAlpha25 = Color.Argb (64, 255, 255, 255);
//var whiteAlpha70 = Color.Argb (64, 255, 255, 255);
var start = new PointF ();
var end = new PointF ();
using (Path path = new Path ()) {
var count = hourly ? HourlyTemps.Count : (Forecasts.Count * 2);
for (int i = 0; i < count; i++) {
// adjusted index
var ai = i;
double temp;
if (hourly) {
temp = HourlyTemps [ai];
} else {
// reset start when switching from highs to lows
if (i == Forecasts.Count) start = new PointF ();
var highs = i < Forecasts.Count;
ai = highs ? i : i - Forecasts.Count;
temp = highs ? HighTemps [ai] : LowTemps [ai];
}
var percent = ((float)temp - scaleLow) / scaleRange;
x = padding + inset + (ai * scaleX);
y = graphRect.Bottom - (graphRect.Height () * percent);
end = new PointF (x, y);
if (!hourly) {
path.AddCircle (end.X - lineWidth, end.Y - lineWidth, lineWidth / 2, Path.Direction.Cw);
}
if (start.IsEmpty ()) {
path.MoveTo (end);
} else {
path.MoveTo (start);
if (hourly) {
path.LineTo (end);
} else {
var diff = (end.X - start.X) / 2;
path.CubicTo (end.X - diff, start.Y, start.X + diff, end.Y, end.X, end.Y);
}
}
start = end;
}
paint.Color = whiteAlpha25;
paint.StrokeWidth = lineWidth;
paint.SetStyle (Paint.Style.Stroke);
canvas.DrawPath (path, paint);
}
}