本文整理汇总了C#中Android.Graphics.Canvas.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.Scale方法的具体用法?C# Canvas.Scale怎么用?C# Canvas.Scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.Scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
protected override void OnDraw(Canvas canvas) {
base.OnDraw (canvas);
if (mBlurredView != null) {
if (prepare()) {
// If the background of the blurred view is a color drawable, we use it to clear
// the blurring canvas, which ensures that edges of the child views are blurred
// as well; otherwise we clear the blurring canvas with a transparent color.
if (mBlurredView.Background != null && mBlurredView.Background is ColorDrawable){
mBitmapToBlur.EraseColor(((ColorDrawable) mBlurredView.Background).Color);
}else {
mBitmapToBlur.EraseColor(Color.Transparent);
}
mBlurredView.Draw(mBlurringCanvas);
blur();
canvas.Save();
canvas.Translate(mBlurredView.GetX() - GetX(), mBlurredView.GetY() - GetY());
canvas.Scale(mDownsampleFactor, mDownsampleFactor);
canvas.DrawBitmap(mBlurredBitmap, 0, 0, null);
canvas.Restore();
}
canvas.DrawColor(mOverlayColor);
}
}
示例2: 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);
}
示例3: OnDraw
protected override void OnDraw (Canvas canvas)
{
base.OnDraw (canvas);
canvas.Save ();
canvas.Translate (_posX, _posY);
canvas.Scale (_scaleFactor, _scaleFactor);
_icon.Draw (canvas);
canvas.Restore ();
}
示例4: DrawAt
protected void DrawAt(Canvas canvas, Drawable drawable, int x, int y, bool shadow)
{
try
{
canvas.Save();
canvas.Translate(x, y);
if (shadow)
{
drawable.SetColorFilter(Util.Int32ToColor(2130706432), PorterDuff.Mode.SrcIn);
canvas.Skew(-0.9F, 0.0F);
canvas.Scale(1.0F, 0.5F);
}
drawable.Draw(canvas);
if (shadow)
{
drawable.ClearColorFilter();
}
}
finally
{
canvas.Restore();
}
}
示例5: Draw
public override void Draw(Canvas canvas)
{
base.Draw (canvas);
DrawWater (canvas);
var center = Width / 2;
descPaint.GetTextBounds (desc, 0, desc.Length, bounds);
canvas.DrawText (desc, center, padding + bounds.Height (), descPaint);
var dt = prefs.GetDisplayDistance (Distance, strictValue: true);
var unit = prefs.GetUnitForDistance (Distance);
digitPaint.GetTextBounds (dt, 0, dt.Length, bounds);
canvas.Save ();
canvas.Scale (1 - currentEffect, (1 - currentEffect) * .4f + .6f, center, Height / 2);
digitPaint.Alpha = (int)((1 - currentEffect) * 255);
canvas.DrawText (dt, center, Height / 2 + bounds.Height () / 2, digitPaint);
canvas.Restore ();
canvas.DrawText (unit, center, Height - 1.2f * padding, unitPaint);
}
示例6: OnDraw
protected override void OnDraw(Canvas canvas)
{
canvas.DrawColor(Color.Transparent);
var p = new Paint()
{
AntiAlias = true
};
SetLayerType(LayerType.Software, p);
var now = SystemClock.UptimeMillis();
if (movieStart == 0)
movieStart = now;
if (movie != null)
{
int dur = movie.Duration();
if (dur == 0)
dur = 1000;
var relTime = (int)((now - movieStart) % dur);
movie.SetTime(relTime);
var movieWidth = (float)movie.Width();
var movieHeight = (float)movie.Height();
var scale = 1.0f;
if (movieWidth > movieHeight)
{
scale = Width / movieWidth;
if (scale * movieHeight > Height)
scale = Height / movieHeight;
}
else
{
scale = Height / movieHeight;
if (scale * movieWidth > Width)
scale = Height / movieWidth;
}
canvas.Scale(scale, scale);
try
{
movie.Draw(canvas, 0, 0, p);
}
catch (Exception ex)
{
Console.WriteLine("Exception thrown in OnDraw : {0}--{1}", ex.Message, ex.StackTrace);
}
if (playing)
Invalidate();
}
}
示例7: OnDraw
protected override void OnDraw(Canvas canvas)
{
canvas.DrawColor(Color.Transparent);
Paint p = new Paint();
p.AntiAlias = true;
SetLayerType(LayerType.Software, p);
long now = Android.OS.SystemClock.UptimeMillis();
if (movieStart == 0)
{ // first time
movieStart = now;
}
if (movie != null)
{
int dur = movie.Duration();
if (dur == 0)
{
dur = 1000;
}
var relTime = (int)((now - movieStart) % dur);
movie.SetTime(relTime);
var movieWidth = (float)movie.Width();
var movieHeight = (float)movie.Height();
var scale = 1.0f;
if (movieWidth > movieHeight)
{
scale = this.Width/movieWidth;
if (scale*movieHeight > Height)
scale = Height/movieHeight;
}
else
{
scale = this.Height/movieHeight;
if (scale*movieWidth > Width)
scale = Height/movieWidth;
}
canvas.Scale(scale, scale);
try
{
movie.Draw(canvas, 0, 0, p);
}catch(Exception ex)
{
}
if(playing)
Invalidate();
}
}
示例8: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
//TODO: Step 7 - Apply Gesture updates
canvas.Save();
canvas.Translate(_posX, _posY);
canvas.Scale(_scaleFactor, _scaleFactor);
_icon.Draw(canvas);
canvas.Restore();
}
示例9: OnDraw
protected override void OnDraw (Canvas canvas)
{
base.OnDraw (canvas);
// Clear screen to pink.
paint.Color = new Color (255, 204, 204);
canvas.DrawPaint (paint);
// Overall transforms to shift (0, 0) to center and scale.
canvas.Translate (this.Width / 2, this.Height / 2);
float scale = Math.Min (this.Width, this.Height) / 2.0f / 100;
canvas.Scale (scale, scale);
// Attributes for tick marks.
paint.Color = Color.Black;
paint.StrokeCap = Paint.Cap.Round;
paint.SetStyle (Paint.Style.Stroke);
// Set line dash to draw tick marks for every minute.
paint.StrokeWidth = 3;
paint.SetPathEffect (minuteTickDashEffect);
canvas.DrawPath (tickMarks, paint);
// Set line dash to draw tick marks for every hour.
paint.StrokeWidth = 6;
paint.SetPathEffect (hourTickDashEffect);
canvas.DrawPath (tickMarks, paint);
// Set attributes common to all clock hands.
Color strokeColor = Color.Black;
Color fillColor = Color.Blue;
paint.StrokeWidth = 2;
paint.SetPathEffect (null);
// Draw hour hand.
canvas.Save ();
canvas.Rotate (this.hourAngle);
paint.Color = fillColor;
paint.SetStyle (Paint.Style.Fill);
canvas.DrawPath (hourHand, paint);
paint.Color = strokeColor;
paint.SetStyle (Paint.Style.Stroke);
canvas.DrawPath (hourHand, paint);
canvas.Restore ();
// Draw minute hand.
canvas.Save ();
canvas.Rotate (this.minuteAngle);
paint.Color = fillColor;
paint.SetStyle (Paint.Style.Fill);
canvas.DrawPath (minuteHand, paint);
paint.Color = strokeColor;
paint.SetStyle (Paint.Style.Stroke);
canvas.DrawPath (minuteHand, paint);
canvas.Restore ();
// Draw second hand.
canvas.Save ();
canvas.Rotate (this.secondAngle);
paint.Color = strokeColor;
paint.SetStyle (Paint.Style.Stroke);
canvas.DrawPath (secondHand, paint);
canvas.Restore ();
}
示例10: transformCanvas
public void transformCanvas(Canvas canvas, float percentOpen)
{
float scale = (float)(percentOpen * 0.25 + 0.75);
canvas.Scale(scale, scale, canvas.Width / 2, canvas.Height / 2);
}
示例11: OnDraw
protected override void OnDraw(Canvas canvas)
{
lock (this) {
if (mBitmap != null) {
Path path = mPath;
int outer = new Color (192, 192, 192);
int inner = new Color (255, 112, 16);
if (mLastX >= mMaxX) {
mLastX = 0;
Canvas cavas = mCanvas;
float yoffset = mYOffset;
float maxx = mMaxX;
float oneG = SensorManager.StandardGravity * mScale[0];
paint.Color = new Color (170, 170, 170);
cavas.DrawColor (Color.Black);
cavas.DrawLine (0, yoffset, maxx, yoffset, paint);
cavas.DrawLine (0, yoffset + oneG, maxx, yoffset + oneG, paint);
cavas.DrawLine (0, yoffset - oneG, maxx, yoffset - oneG, paint);
}
canvas.DrawBitmap (mBitmap, 0, 0, null);
float[] values = mOrientationValues;
if (mWidth < mHeight) {
float w0 = mWidth * 0.333333f;
float w = w0 - 32;
float x = w0 * 0.5f;
for (int i = 0; i < 3; i++) {
canvas.Save (SaveFlags.Matrix);
canvas.Translate (x, w * 0.5f + 4.0f);
canvas.Save (SaveFlags.Matrix);
paint.Color = outer;
canvas.Scale (w, w);
canvas.DrawOval (mRect, paint);
canvas.Restore ();
canvas.Scale (w - 5, w - 5);
paint.Color = inner;
canvas.Rotate (-values[i]);
canvas.DrawPath (path, paint);
canvas.Restore ();
x += w0;
}
} else {
float h0 = mHeight * 0.333333f;
float h = h0 - 32;
float y = h0 * 0.5f;
for (int i = 0; i < 3; i++) {
canvas.Save (SaveFlags.Matrix);
canvas.Translate (mWidth - (h * 0.5f + 4.0f), y);
canvas.Save (SaveFlags.Matrix);
paint.Color = outer;
canvas.Scale (h, h);
canvas.DrawOval (mRect, paint);
canvas.Restore ();
canvas.Scale (h - 5, h - 5);
paint.Color = inner;
canvas.Rotate (-values[i]);
canvas.DrawPath (path, paint);
canvas.Restore ();
y += h0;
}
}
}
}
}
示例12: DrawPict
private void DrawPict(Canvas canvas, int x, int y, int w, int h, float sx, float sy)
{
canvas.Save ();
canvas.Translate (x, y);
canvas.ClipRect (0, 0, w, h);
canvas.Scale (0.5f, 0.5f);
canvas.Scale (sx, sy, w, h);
canvas.DrawPicture (mPicture);
canvas.Restore ();
}
示例13: drawCircle
/**
* Draws a circle centered in the view.
*
* @param canvas the canvas to draw on
* @param cx the center x coordinate
* @param cy the center y coordinate
* @param color the color to draw
* @param pct the percentage of the view that the circle should cover
*/
private void drawCircle(Canvas canvas, float cx, float cy, int color, float pct) {
mPaint.Color = Android.Graphics.Color.Brown;
//mPaint.SetColor(color);
canvas.Save();
canvas.Translate (cx, cy);
float radiusScale = INTERPOLATOR.GetInterpolation (pct);
canvas.Scale(radiusScale, radiusScale);
canvas.DrawCircle(0, 0, cx, mPaint);
canvas.Restore();
}
示例14: prepare
protected bool prepare() {
int width = mBlurredView.Width;
int height = mBlurredView.Height;
if (mBlurringCanvas == null || mDownsampleFactorChanged
|| mBlurredViewWidth != width || mBlurredViewHeight != height) {
mDownsampleFactorChanged = false;
mBlurredViewWidth = width;
mBlurredViewHeight = height;
int scaledWidth = width / mDownsampleFactor;
int scaledHeight = height / mDownsampleFactor;
// The following manipulation is to avoid some RenderScript artifacts at the edge.
scaledWidth = scaledWidth - scaledWidth % 4 + 4;
scaledHeight = scaledHeight - scaledHeight % 4 + 4;
if (mBlurredBitmap == null
|| mBlurredBitmap.Width != scaledWidth
|| mBlurredBitmap.Height != scaledHeight) {
mBitmapToBlur = Bitmap.CreateBitmap(scaledWidth, scaledHeight,
Bitmap.Config.Argb8888);
if (mBitmapToBlur == null) {
return false;
}
mBlurredBitmap = Bitmap.CreateBitmap(scaledWidth, scaledHeight,
Bitmap.Config.Argb8888);
if (mBlurredBitmap == null) {
return false;
}
}
mBlurringCanvas = new Canvas(mBitmapToBlur);
mBlurringCanvas.Scale(1f / mDownsampleFactor, 1f / mDownsampleFactor);
mBlurInput = Allocation.CreateFromBitmap(mRenderScript, mBitmapToBlur,
Allocation.MipmapControl.MipmapNone,AllocationUsage.Script);
mBlurOutput = Allocation.CreateTyped(mRenderScript, mBlurInput.Type);
}
return true;
}
示例15: Draw
public override void Draw (Canvas canvas)
{
if (flip) {
canvas.Save();
canvas.Scale(1f, -1f, IntrinsicWidth / 2, IntrinsicHeight / 2);
}
topLine.draw(canvas);
middleLine.draw(canvas);
bottomLine.draw(canvas);
if (flip) canvas.Restore();
// throw new NotImplementedException ();
}