本文整理汇总了C#中Android.Graphics.RectF类的典型用法代码示例。如果您正苦于以下问题:C# RectF类的具体用法?C# RectF怎么用?C# RectF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RectF类属于Android.Graphics命名空间,在下文中一共展示了RectF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRoundedCornerBitmap
// If you would like to create a circle of the image set pixels to half the width of the image.
internal static Bitmap GetRoundedCornerBitmap(Bitmap bitmap, int pixels)
{
Bitmap output = null;
try
{
output = Bitmap.CreateBitmap(bitmap.Width, bitmap.Height, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(output);
Color color = new Color(66, 66, 66);
Paint paint = new Paint();
Rect rect = new Rect(0, 0, bitmap.Width, bitmap.Height);
RectF rectF = new RectF(rect);
float roundPx = pixels;
paint.AntiAlias = true;
canvas.DrawARGB(0, 0, 0, 0);
paint.Color = color;
canvas.DrawRoundRect(rectF, roundPx, roundPx, paint);
paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
canvas.DrawBitmap(bitmap, rect, rect, paint);
}
catch (System.Exception err)
{
System.Console.WriteLine ("GetRoundedCornerBitmap Error - " + err.Message);
}
return output;
}
示例2: GenerateNextTransition
public Transition GenerateNextTransition(RectF drawableBounds, RectF viewport)
{
bool firstTransition = _mLastGenTrans == null;
bool drawableBoundsChanged = true;
bool viewportRatioChanged = true;
RectF srcRect = null;
RectF dstRect = null;
if (!firstTransition)
{
dstRect = _mLastGenTrans.GetDestinyRect();
drawableBoundsChanged = !drawableBounds.Equals(_mLastDrawableBounds);
viewportRatioChanged = !MathUtils.HaveSameAspectRatio(dstRect, viewport);
}
if (dstRect == null || drawableBoundsChanged || viewportRatioChanged)
{
srcRect = GenerateRandomRect(drawableBounds, viewport);
}
else
{
/* Sets the destiny rect of the last transition as the source one
if the current drawable has the same dimensions as the one of
the last transition. */
srcRect = dstRect;
}
dstRect = GenerateRandomRect(drawableBounds, viewport);
_mLastGenTrans = new Transition(srcRect, dstRect, _mTransitionDuration,
_mTransitionIInterpolator);
_mLastDrawableBounds = drawableBounds;
return _mLastGenTrans;
}
示例3: 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();
}
}
示例4: Draw
public override void Draw(Android.Graphics.Canvas canvas)
{
base.Draw (canvas);
Paint mBgPaints = new Paint ();
mBgPaints.AntiAlias = true;
mBgPaints.SetStyle (Paint.Style.Fill);
mBgPaints.Color = Color.Blue;
mBgPaints.StrokeWidth = 0.5f;
Paint tPaint = new Paint ();
tPaint.Alpha = 0;
canvas.DrawColor (tPaint.Color);
RectF mOvals = new RectF (40, 40, layout.MeasuredWidth - 40, layout.MeasuredHeight - 40);
decimal total = 0;
foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
total += value.amount;
}
if (total == 0) {
return;
}
decimal degressPerAmount = 360 / total;
decimal currentAngle = 0;
foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
canvas.DrawArc (mOvals, (float)currentAngle, (float)(degressPerAmount * value.amount), true, mBgPaints);
currentAngle += (degressPerAmount * value.amount);
mBgPaints.SetARGB (255, new Random ().Next (256), new Random ().Next (256), new Random ().Next (256));
}
}
示例5: 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();
}
}
示例6: parse
public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint, RectF pRect) {
float? centerX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_X);
float? centerY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_Y);
float? radiusX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_X);
float? radiusY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS_Y);
if (centerX != null && centerY != null && radiusX != null && radiusY != null) {
pRect.Set(centerX.Value - radiusX.Value,
centerY.Value - radiusY.Value,
centerX.Value + radiusX.Value,
centerY.Value + radiusY.Value);
bool fill = pSVGPaint.setFill(pSVGProperties);
if (fill) {
pCanvas.DrawOval(pRect, pSVGPaint.getPaint());
}
bool stroke = pSVGPaint.setStroke(pSVGProperties);
if (stroke) {
pCanvas.DrawOval(pRect, pSVGPaint.getPaint());
}
if(fill || stroke) {
pSVGPaint.ensureComputedBoundsInclude(centerX.Value - radiusX.Value, centerY.Value - radiusY.Value);
pSVGPaint.ensureComputedBoundsInclude(centerX.Value + radiusX.Value, centerY.Value + radiusY.Value);
}
}
}
示例7: OnDraw
protected override void OnDraw(Canvas canvas)
{
Android.Graphics.Drawable.Drawable drawable = GetDrawable();
if (drawable is BitmapDrawable)
{
RectF rectF = new RectF(drawable.GetBounds());
int restoreCount = canvas.SaveLayer(rectF, null, Canvas.AllSaveFlag);
GetImageMatrix().MapRect(rectF);
Paint paint = ((BitmapDrawable)drawable).GetPaint();
paint.SetAntiAlias(true);
paint.SetColor(unchecked((int)(0xff000000)));
canvas.DrawARGB(0, 0, 0, 0);
canvas.DrawRoundRect(rectF, Radius, Radius, paint);
Xfermode restoreMode = paint.GetXfermode();
paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
base.OnDraw(canvas);
// Restore paint and canvas
paint.SetXfermode(restoreMode);
canvas.RestoreToCount(restoreCount);
}
else
{
base.OnDraw(canvas);
}
}
示例8: ToRounded
public static Bitmap ToRounded(Bitmap source, float rad)
{
int size = Math.Min(source.Width, source.Height);
int dx = (source.Width - size) / 2;
int dy = (source.Height - size) / 2;
Bitmap bitmap = Bitmap.CreateBitmap(size, size, 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())
{
if (dx != 0 || dy != 0)
{
// source isn't square, move viewport to centre
matrix.SetTranslate(-dx, -dy);
shader.SetLocalMatrix(matrix);
}
paint.SetShader(shader);
paint.AntiAlias = true;
RectF rectF = new RectF(0, 0, size, size);
canvas.DrawRoundRect(rectF, rad, rad, paint);
return bitmap;
}
}
示例9: HandleShapeDraw
protected virtual void HandleShapeDraw (Canvas canvas)
{
// We need to account for offsetting the coordinates based on the padding
var x = GetX () + Resize (this.ShapeView.Padding.Left);
var y = GetY () + Resize (this.ShapeView.Padding.Top);
switch (ShapeView.ShapeType) {
case ShapeType.Box:
HandleStandardDraw (canvas, p => {
var rect = new RectF (x, y, x + this.Width, y + this.Height);
if (ShapeView.CornerRadius > 0) {
var cr = Resize (ShapeView.CornerRadius);
canvas.DrawRoundRect (rect, cr, cr, p);
} else {
canvas.DrawRect (rect, p);
}
});
break;
case ShapeType.Circle:
HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p));
break;
case ShapeType.CircleIndicator:
HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p), drawFill: false);
HandleStandardDraw (canvas, p => canvas.DrawArc (new RectF (x, y, x + this.Width, y + this.Height), QuarterTurnCounterClockwise, 360 * (ShapeView.IndicatorPercentage / 100), false, p), ShapeView.StrokeWidth + 3, false);
break;
}
}
示例10: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw (canvas);
var stokewidth = TapUtil.dptodx (this.stokewidthdp);
var progresswidth = TapUtil.dptodx (this.progresswidthdp);
//draw border
int center = Width / 2;
nn_paint.SetStyle(Paint.Style.Stroke);
nn_paint.Color=nn_outcolor;
nn_paint.StrokeWidth = stokewidth;
canvas.DrawCircle(center,center, nn_radius-stokewidth, nn_paint);
//draw remainingsection of progress
nn_paint.SetStyle (Paint.Style.Fill);
nn_paint.Color=nn_progressremainingcolor;
//RectF position is relative toparent
canvas.DrawCircle(center,center, nn_radius-stokewidth*2, nn_paint);
//draw progress
nn_paint.SetStyle (Paint.Style.Stroke);
nn_paint.Color=nn_progresscolor;
nn_paint.StrokeWidth = progresswidthdp*2;
//RectF position is relative toparent
RectF oval = new RectF (0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5));
canvas.DrawArc(oval, progresssstartangle, progresssendangle, false, nn_paint);
//draw avatarcontainer (innercircle)
nn_paint.SetStyle(Paint.Style.Fill);
nn_paint.Color=nn_innercontainercolor;
canvas.DrawCircle(center,center, nn_radius-progresswidth-stokewidth*2, nn_paint);
}
示例11: CircleDrawable
public CircleDrawable(Bitmap bmp)
{
this.bmp = bmp;
this.bmpShader = new BitmapShader(bmp, Shader.TileMode.Clamp, Shader.TileMode.Clamp);
this.paint = new Paint() { AntiAlias = true };
this.paint.SetShader(bmpShader);
this.oval = new RectF();
}
示例12: DrawOutline
private static void DrawOutline(Canvas canvas, IStyle style, RectF destination)
{
var vectorStyle = (style as VectorStyle);
if (vectorStyle == null) return;
if (vectorStyle.Outline == null) return;
if (vectorStyle.Outline.Color == null) return;
DrawRectangle(canvas, destination, vectorStyle.Outline.Color);
}
示例13: DrawRectangle
private static void DrawRectangle(Canvas canvas, RectF destination, Styles.Color outlineColor)
{
var paint = new Paint();
paint.SetStyle(Paint.Style.Stroke);
paint.Color = new AndroidColor(outlineColor.R, outlineColor.G, outlineColor.B, outlineColor.A);
paint.StrokeWidth = 4;
canvas.DrawRect(destination, paint);
}
示例14: DrawRectBounds
public override void DrawRectBounds( FastColour colour, float lineWidth, int x, int y, int width, int height )
{
RectF rec = new RectF( x, y, x + width, y + height );
Paint brush = GetOrCreateBrush( colour );
brush.SetStyle( Paint.Style.Stroke );
c.DrawRect( rec, brush );
brush.SetStyle( Paint.Style.FillAndStroke );
}
示例15: Clear
public override void Clear( FastColour colour, int x, int y, int width, int height )
{
RectF rec = new RectF( x, y, x + width, y + height );
Paint brush = GetOrCreateBrush( colour );
brush.AntiAlias = false;
c.DrawRect( rec, brush );
brush.AntiAlias = true;
}