当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.Scale方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:takigava,项目名称:Glass,代码行数:25,代码来源:BlurringView.cs

示例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);
        }
开发者ID:adolfo7x,项目名称:Play.Stopwatch,代码行数:27,代码来源:StopwatchView.cs

示例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 ();
		}
开发者ID:Vaikesh,项目名称:Drag-Drop_Dragable-View_Xamarin.Android,代码行数:9,代码来源:DragView.cs

示例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();
            }
        }
开发者ID:knji,项目名称:mvvmcross.plugins,代码行数:24,代码来源:Style.cs

示例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);
        }
开发者ID:modulexcite,项目名称:bikr,代码行数:21,代码来源:CircleBadge.cs

示例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();
            }
        }
开发者ID:nodoid,项目名称:AnimatedGif,代码行数:47,代码来源:MainActivity.cs

示例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();
      }
    }
开发者ID:phaufe,项目名称:PuppyKittyOverflow,代码行数:53,代码来源:AnimatedImageView.cs

示例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();
        }
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:12,代码来源:GestureRecognizerView.cs

示例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 ();
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:64,代码来源:ClockView.cs

示例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);
 }
开发者ID:skywolf888,项目名称:SlidingMenu.Net,代码行数:5,代码来源:CustomZoomAnimation.cs

示例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;
                            }
                        }

                    }
                }
            }
开发者ID:rudini,项目名称:monodroid-samples,代码行数:66,代码来源:Sensors.cs

示例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 ();
 }
开发者ID:vkheleli,项目名称:monodroid-samples-master,代码行数:10,代码来源:PictureLayout.cs

示例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();
			}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:19,代码来源:ActionProcessButton.cs

示例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;
		}
开发者ID:takigava,项目名称:Glass,代码行数:42,代码来源:BlurringView.cs

示例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 ();
		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:13,代码来源:DrawerArrowDrawable.cs


注:本文中的Android.Graphics.Canvas.Scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。