protected override void OnDraw(Canvas canvas)
        {
            canvas.Save();
            if (RotationPivotPoint != null) {
                canvas.Rotate(RotationDegress, RotationPivotPoint.X, RotationPivotPoint.Y);
            } else {
                canvas.Rotate(RotationDegress);
            }

            base.OnDraw(canvas);
        }
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            canvas.Save();

            canvas.Translate(_width, _height);
            canvas.Rotate(-90);

            TextPaint paint = this.Paint;

            //Android.Graphics.Color Colorr = Color.  //this.TextColors.DefaultColor;
            //
            //var defcolor = this.TextColors.DefaultColor;
            //var Redd = Color.GetRedComponent(defcolor);
            //var Blue = Color.GetBlueComponent(defcolor);
            //var Greenn = Color.GetGreenComponent(defcolor);
            //var Birlestir = Color.Rgb(Redd, Greenn, Blue);
            //ColorFilter cf = new PorterDuffColorFilter(Birlestir, PorterDuff.Mode.SrcAtop);
            //paint.SetColorFilter(cf);
            paint.Color = Color.White;
            String text = getTextt();

            paint.GetTextBounds(text, 0, text.Length, _bounds);
            canvas.DrawText(text, this.CompoundPaddingLeft, (_bounds.Height() - _width) / 2, paint);

            canvas.Restore();
        }
Esempio n. 3
0
 public void Draw(Canvas canvas)
 {
     canvas.Save();
     canvas.Translate((float)Position.X, (float)Position.Y);
     canvas.Rotate((float)Acceleration.Direction + ROTATION_OFFSET);
     mDrawable.Draw(canvas);
     canvas.Restore();
 }
Esempio n. 4
0
		public static Bitmap ToRotatedBitmap(this Bitmap sourceBitmap, int rotationDegrees)
		{
			if (rotationDegrees == 0)
				return sourceBitmap;

			int width = sourceBitmap.Width;
			int height = sourceBitmap.Height;

			if (rotationDegrees == 90 || rotationDegrees == 270)
			{
				width = sourceBitmap.Height;
				height = sourceBitmap.Width;
			}

			Bitmap bitmap = Bitmap.CreateBitmap(width, height, sourceBitmap.GetConfig());
			using (Canvas canvas = new Canvas(bitmap))
			using (Paint paint = new Paint())
			using (BitmapShader shader = new BitmapShader(sourceBitmap, Shader.TileMode.Clamp, Shader.TileMode.Clamp))
			using (Matrix matrix = new Matrix())
			{
				// paint.AntiAlias = true;
				// paint.Dither = true;
				// paint.FilterBitmap = true;

				canvas.Save(Android.Graphics.SaveFlags.Matrix);

				if (rotationDegrees == 90)
					canvas.Rotate(rotationDegrees, width / 2, width / 2);
				else if (rotationDegrees == 270)
					canvas.Rotate(rotationDegrees, height / 2, height / 2);
				else
					canvas.Rotate(rotationDegrees, width / 2, height / 2);

				canvas.DrawBitmap(sourceBitmap, matrix, paint);
				canvas.Restore();
			}

			if (sourceBitmap != null && sourceBitmap.Handle != IntPtr.Zero && !sourceBitmap.IsRecycled)
			{
				sourceBitmap.Recycle();
				sourceBitmap.Dispose();
			}

			return bitmap;
		}
Esempio n. 5
0
        // Rotate the canvas before drawing
        protected override void DispatchDraw(Canvas canvas)
        {
            canvas.Save (SaveFlags.Matrix);
            canvas.Rotate (-heading, Width * 0.5f, Height * 0.5f);

            base.DispatchDraw (canvas);

            canvas.Restore ();
        }
Esempio n. 6
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);
            mCurrentBounds.Set(mTempBounds);

            float outerCircleRadius = Math.Min(mTempBounds.Height(), mTempBounds.Width()) / 2.0f;
            float interCircleRadius = outerCircleRadius / 2.0f;
            float centerRingWidth   = interCircleRadius - mStrokeWidth / 2;

            mPaint.SetStyle(Paint.Style.Stroke);
            mPaint.Color       = new Color(mColor);
            mPaint.StrokeWidth = mStrokeWidth;
            canvas.DrawCircle(mTempBounds.CenterX(), mTempBounds.CenterY(), outerCircleRadius, mPaint);
            mPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawCircle(mTempBounds.CenterX(), mTempBounds.CenterY(), interCircleRadius * mScale, mPaint);

            if (mRotation != 0)
            {
                mPaint.Color = new Color(mArcColor);
                mPaint.SetStyle(Paint.Style.Stroke);
                //strokeWidth / 2.0f + mStrokeWidth / 2.0f is the center of the inter circle width
                mTempBounds.Inset(centerRingWidth / 2.0f + mStrokeWidth / 2.0f, centerRingWidth / 2.0f + mStrokeWidth / 2.0f);
                mPaint.StrokeWidth = centerRingWidth;
                canvas.DrawArc(mTempBounds, RING_START_ANGLE, mRotation, false, mPaint);
            }

            mPaint.Color = new Color(mColor);
            mPaint.SetStyle(Paint.Style.Fill);
            for (int i = 0; i < NUM_POINTS; i++)
            {
                canvas.Rotate(i * DANCE_INTERVAL_ANGLE, POINT_X[i], POINT_Y[i]);
                RectF rectF = new RectF(POINT_X[i] - mDanceBallRadius - mShapeChangeWidth / 2.0f, POINT_Y[i] - mDanceBallRadius - mShapeChangeHeight / 2.0f, POINT_X[i] + mDanceBallRadius + mShapeChangeWidth / 2.0f, POINT_Y[i] + mDanceBallRadius + mShapeChangeHeight / 2.0f);
                canvas.DrawOval(rectF, mPaint);
                canvas.Rotate(-i * DANCE_INTERVAL_ANGLE, POINT_X[i], POINT_Y[i]);
            }

            canvas.RestoreToCount(saveCount);
        }
Esempio n. 7
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int SaveCount = canvas.Save();

            RectF arcBounds = mCurrentBounds;

            arcBounds.Set(bounds);

            //Draw background
            canvas.DrawColor(new Color(mCurrentBackgroundColor));
            //Draw reveal circle
            if (mRevealCircleRadius > 0)
            {
                mPaint.Color = new Color(mCurrentBackgroundColor == mBackgroundColor ? mBackgroundDeepColor : mBackgroundColor);
                canvas.DrawCircle(arcBounds.CenterX(), arcBounds.CenterY(), mRevealCircleRadius, mPaint);
            }

            //Draw mother oval
            mPaint.Color = new Color(mCurrentOvalColor);

            int motherSaveCount = canvas.Save();

            canvas.Rotate(mRotateDegrees, mMotherPosition[0], mMotherPosition[1]);
            canvas.DrawPath(CreateMotherPath(), mPaint);
            canvas.DrawPath(CreateLinkPath(), mPaint);
            canvas.RestoreToCount(motherSaveCount);

            int childSaveCount = canvas.Save();

            canvas.Rotate(mRotateDegrees, mChildPosition[0], mChildPosition[1]);
            canvas.DrawPath(CreateChildPath(), mPaint);
            canvas.RestoreToCount(childSaveCount);
            canvas.RestoreToCount(SaveCount);

            //    canvas.DrawPath(mMotherMovePath, mPaint);
            //    canvas.DrawPath(mChildMovePath, mPaint);
            //    canvas.DrawLine(mMotherPosition[0], mMotherPosition[1], mChildPosition[0], mChildPosition[1], mPaint);
        }
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            var textPaint = this.Paint;

            textPaint.Color = new Color(this.CurrentTextColor);

            canvas.Save();

            if (m_TopDown)
            {
                canvas.Translate(this.Width, 0);
                canvas.Rotate(90.0f);
            }
            else
            {
                canvas.Translate(0, this.Height);
                canvas.Rotate(-90.0f);
            }

            canvas.Translate(this.CompoundPaddingLeft, this.ExtendedPaddingTop);
            this.Layout.Draw(canvas);
            canvas.Restore();
        }
Esempio n. 9
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);

            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            if (mSwipeDegrees != 0)
            {
                mPaint.Color = new Color(mCurrentColor);
                canvas.DrawArc(mTempBounds, mStartDegrees, mSwipeDegrees, false, mPaint);
            }

            canvas.RestoreToCount(saveCount);
        }
        public override void Draw(Canvas canvas, ICharSequence text, Int32 start, Int32 end, Single x, Int32 top, Int32 y, Int32 bottom, Paint paint)
        {
            ApplyCustomTypeFace(paint, _type);
            paint.GetTextBounds(_icon, 0, 1, TEXT_BOUNDS);
            canvas.Save();
            var baselineRatio = _baselineAligned ? 0f : BASELINE_RATIO;
            if (_rotate)
            {
                var rotation = (SystemClock.CurrentThreadTimeMillis() - _rotationStartTime) / (Single)ROTATION_DURATION * 360f;
                var centerX = x + TEXT_BOUNDS.Width() / 2f;
                var centerY = y - TEXT_BOUNDS.Height() / 2f + TEXT_BOUNDS.Height() * baselineRatio;
                canvas.Rotate(rotation, centerX, centerY);
            }

            canvas.DrawText(_icon, x - TEXT_BOUNDS.Left, y - TEXT_BOUNDS.Bottom + TEXT_BOUNDS.Height() * baselineRatio, paint);
            canvas.Restore();
        }
Esempio n. 11
0
        public override void Draw(Canvas canvas, ICharSequence text, int start, int end, float x, int top, int y,
            int bottom, Paint paint)
        {
            ApplyCustomTypeFace(paint, _typeface);
            paint.GetTextBounds(_icon, 0, 1, TextBounds);
            canvas.Save();
            if (_rotate)
            {
                var rotation = (DateTimeHelpers.CurrentUnixTimeMillis() - _rotationStartTime)/(float) RotationDuration*
                               360f;
                var centerX = x + TextBounds.Width()/2f;
                var centerY = y - TextBounds.Height()/2f + TextBounds.Height()*BaselineRatio;
                canvas.Rotate(rotation, centerX, centerY);
            }

            canvas.DrawText(_icon, x - TextBounds.Left, y - TextBounds.Bottom + TextBounds.Height()*BaselineRatio,
                paint);
            canvas.Restore();
        }
Esempio n. 12
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);
            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            for (int i = 0; i < 3; i++)
            {
                if (mLevelSwipeDegrees[i] != 0)
                {
                    mPaint.Color = new Color(mLevelColors[i]);
                    canvas.DrawArc(mTempBounds, mEndDegrees, mLevelSwipeDegrees[i], false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
        public override void Draw(Canvas canvas, ICharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
        {
            ApplyCustomTypeFace(paint, type);
            paint.GetTextBounds(icon, 0, 1, TEXT_BOUNDS);
            canvas.Save();
            float baselineRatio = baselineAligned ? 0f : BASELINE_RATIO;
            if (rotate)
            {
                long time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                float rotation = (time - rotationStartTime) / (float)ROTATION_DURATION * 360f;
                float centerX = x + TEXT_BOUNDS.Width() / 2f;
                float centerY = y - TEXT_BOUNDS.Height() / 2f + TEXT_BOUNDS.Height() * baselineRatio;
                canvas.Rotate(rotation, centerX, centerY);
            }

            canvas.DrawText(icon,
                    x - TEXT_BOUNDS.Left,
                    y - TEXT_BOUNDS.Bottom + TEXT_BOUNDS.Height() * baselineRatio, paint);
            canvas.Restore();
        }
Esempio n. 14
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInSet, mStrokeInSet);

            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            if (mSwipeDegrees != 0)
            {
                for (int i = 0; i < mColors.Length; i++)
                {
                    mPaint.StrokeWidth = mStrokeWidth / (i + 1);
                    mPaint.Color       = new Color(mColors[i]);
                    canvas.DrawArc(CreateArcBounds(mTempBounds, i), mStartDegrees + DEGREE_180 * (i % 2), mSwipeDegrees, false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
Esempio n. 15
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            // Fill the background
            canvas.DrawPaint(mBackgroundPaint);

            // Test Text
            canvas.Save();
            var  textWidth  = mTextPaint.MeasureText("Hello");
            Rect textBounds = new Rect();

            mTextPaint.GetTextBounds("Hello", 0, 1, textBounds);
            canvas.DrawText("Hello", canvas.Width / 2 - textWidth / 2, canvas.Height / 2 - textBounds.Height() / 2, mTextPaint);

            textWidth  = mTextPaint.MeasureText("World");
            textBounds = new Rect();
            mTextPaint.GetTextBounds("World", 0, 1, textBounds);
            mTextPaint.Color = Color.Green;
            canvas.DrawText("World", (canvas.Width / 2 - textWidth / 2) + 100, (canvas.Height / 2 - textBounds.Height() / 2) + 100, mTextPaint);


            canvas.Restore();

            foreach (Box box in mBoxes)
            {
                float left   = Math.Min(box.Origin.X, box.Current.X);
                float right  = Math.Max(box.Origin.X, box.Current.X);
                float top    = Math.Min(box.Origin.Y, box.Current.Y);
                float bottom = Math.Max(box.Origin.Y, box.Current.Y);
                canvas.Save();
                canvas.Rotate(box.Rotation, (box.Origin.X + box.Current.X) / 2, (box.Origin.Y + box.Current.Y) / 2);
                canvas.DrawRect(left, top, right, bottom, mBoxPaint);
                canvas.Restore();
            }
        }
Esempio n. 16
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);
            mTempBounds.Inset(mTempBounds.Width() * (1.0f - mScale) / 2.0f, mTempBounds.Width() * (1.0f - mScale) / 2.0f);

            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            mPaint.Color       = new Color(mColor);
            mPaint.Alpha       = (int)(MAX_ALPHA * mScale);
            mPaint.StrokeWidth = mStrokeWidth * mScale;

            if (mSwipeDegrees != 0)
            {
                for (int i = 0; i < mGearCount; i++)
                {
                    canvas.DrawArc(mTempBounds, mStartDegrees + DEGREE_360 / mGearCount * i, mSwipeDegrees, false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
Esempio n. 17
0
		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 ();
		}
Esempio n. 18
0
			/// <summary>
			/// Draws the ship, fuel/speed bars, and background to the provided
			/// Canvas.
			/// </summary>
			private void DoDraw(Canvas canvas)
			{
				// Draw the background image. Operations on the Canvas accumulate
				// so this is like clearing the screen.
				canvas.DrawBitmap(mBackgroundImage, 0, 0, null);

				int yTop = mCanvasHeight - ((int) mY + mLanderHeight / 2);
				int xLeft = (int) mX - mLanderWidth / 2;

				// Draw the fuel gauge
				int fuelWidth = (int)(UI_BAR * mFuel / PHYS_FUEL_MAX);
				mScratchRect.Set(4, 4, 4 + fuelWidth, 4 + UI_BAR_HEIGHT);
				canvas.DrawRect(mScratchRect, mLinePaint);

				// Draw the speed gauge, with a two-tone effect
				double speed = Math.Sqrt(mDX * mDX + mDY * mDY);
				int speedWidth = (int)(UI_BAR * speed / PHYS_SPEED_MAX);

				if (speed <= mGoalSpeed)
				{
					mScratchRect.Set(4 + UI_BAR + 4, 4, 4 + UI_BAR + 4 + speedWidth, 4 + UI_BAR_HEIGHT);
					canvas.DrawRect(mScratchRect, mLinePaint);
				}
				else
				{
					// Draw the bad color in back, with the good color in front of
					// it
					mScratchRect.Set(4 + UI_BAR + 4, 4, 4 + UI_BAR + 4 + speedWidth, 4 + UI_BAR_HEIGHT);
					canvas.DrawRect(mScratchRect, mLinePaintBad);
					int goalWidth = (UI_BAR * mGoalSpeed / PHYS_SPEED_MAX);
					mScratchRect.Set(4 + UI_BAR + 4, 4, 4 + UI_BAR + 4 + goalWidth, 4 + UI_BAR_HEIGHT);
					canvas.DrawRect(mScratchRect, mLinePaint);
				}

				// Draw the landing pad
				canvas.DrawLine(mGoalX, 1 + mCanvasHeight - TARGET_PAD_HEIGHT, mGoalX + mGoalWidth, 1 + mCanvasHeight - TARGET_PAD_HEIGHT, mLinePaint);


				// Draw the ship with its current rotation
				canvas.Save();
				canvas.Rotate((float) mHeading, (float) mX, mCanvasHeight - (float) mY);
				if (mMode == STATE_LOSE)
				{
					mCrashedImage.SetBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight);
					mCrashedImage.Draw(canvas);
				}
				else if (mEngineFiring)
				{
					mFiringImage.SetBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight);
					mFiringImage.Draw(canvas);
				}
				else
				{
					mLanderImage.SetBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight);
					mLanderImage.Draw(canvas);
				}
				canvas.Restore();
			}
 public override void Draw(Android.Graphics.Canvas canvas)
 {
     canvas.Rotate(-90);
     canvas.Translate(-Height, 0);
     base.OnDraw(canvas);
 }
Esempio n. 20
0
            protected override void OnDraw(Canvas canvas)
            {
                Paint paint = mPaint;

                canvas.DrawColor (Color.White);

                paint.AntiAlias = true;
                paint.Color = Color.Black;
                paint.SetStyle (Paint.Style.Fill);

                int w = canvas.Width;
                int h = canvas.Height;
                int cx = w / 2;
                int cy = h / 2;

                canvas.Translate (cx, cy);

                if (compass.mValues != null)
                    canvas.Rotate (-compass.mValues[0]);

                canvas.DrawPath (mPath, mPaint);
            }
		protected override void OnDraw (Canvas canvas)
		{
			// All of our positions are using our internal coordinate system.
			// Instead of translating
			// them we let Canvas do the work for us.
			canvas.Translate(_translationOffsetX, _translationOffsetY);

			float progressRotation = GetCurrentRotation();

			// draw the background
			if (!_overrdraw) {
				canvas.DrawArc(_circleBounds, 270, -(360 - progressRotation), false,
					_backgroundColorPaint);
			}

			// draw the progress or a full circle if overdraw is true
			canvas.DrawArc(_circleBounds, 270, _overrdraw ? 360 : progressRotation, false,
				_progressColorPaint);

			// draw the marker at the correct rotated position
			if (_isMarkerEnabled) {
				float markerRotation = GetMarkerRotation();

				canvas.Save();
				canvas.Rotate(markerRotation - 90);
				canvas.DrawLine((float) (_thumbPosX + _thumbRadius / 2 * 1.4), _thumbPosY,
					(float) (_thumbPosX - _thumbRadius / 2 * 1.4), _thumbPosY, _markerColorPaint);
				canvas.Restore();
			}

			if (IsThumbEnabled()) {
				// draw the thumb square at the correct rotated position
				canvas.Save();
				canvas.Rotate(progressRotation - 90);
				// rotate the square by 45 degrees
				canvas.Rotate(45, _thumbPosX, _thumbPosY);
				_squareRect.Left = _thumbPosX - _thumbRadius / 3;
				_squareRect.Right = _thumbPosX + _thumbRadius / 3;
				_squareRect.Top = _thumbPosY - _thumbRadius / 3;
				_squareRect.Bottom = _thumbPosY + _thumbRadius / 3;
				canvas.DrawRect(_squareRect, _thumbColorPaint);
				canvas.Restore();
			}
		}
        protected override void OnDraw(Canvas canvas)
        {
            // All of our positions are using our internal coordinate system.
              // Instead of translating
              // them we let Canvas do the work for us.
              canvas.Translate(translationOffsetX, translationOffsetY);
              var progressRotation = CurrentRoatation;

              //draw the background
              if (!overdraw)
              {
            canvas.DrawArc(circleBounds, 270, -(360 - progressRotation), false, backgroundColorPaint);
              }

              //draw the progress or a full circle if overdraw is true
              canvas.DrawArc(circleBounds, 270, overdraw ? 360 : progressRotation, false, progressColorPaint);

              //draw the marker at the correct rortated position
              if (IsMarkerEnabled)
              {
            var markerRotation = MarkerRotation;
            canvas.Save();
            canvas.Rotate(markerRotation - 90);
            canvas.DrawLine(thumbPosX + thumbRadius / 2.0f * 1.4f, thumbPosY,
                        thumbPosX - thumbRadius / 2.0f * 1.4f, thumbPosY, markerColorPaint);
            canvas.Restore();
              }

              //draw the thumb square at the correct rotated position
              canvas.Save();
              canvas.Rotate(progressRotation - 90);
              //rotate the square by 45 degrees
              canvas.Rotate(45, thumbPosX, thumbPosY);
              var rect = new RectF();
              rect.Left = thumbPosX - thumbRadius / 3.0f;
              rect.Right = thumbPosX + thumbRadius / 3.0f;
              rect.Top = thumbPosY - thumbRadius / 3.0f;
              rect.Bottom = thumbPosY + thumbRadius / 3.0f;
              canvas.DrawRect(rect, thumbColorPaint);
              canvas.Restore();
        }
Esempio n. 23
0
        public void DrawSecondsHand(Canvas canvas)
        {
            canvas.Save();
            canvas.Rotate(_seconds * 6);
            
            var paint = new Paint
            {
                Color = Color.Red,
                StrokeWidth = 2
            };
            paint.SetStyle(Paint.Style.Stroke);

            canvas.DrawPath(_secondHand, paint);
            canvas.Restore();
        }
Esempio n. 24
0
        private void DrawBitmap(Canvas c, Bitmap bmp)
        {
            var sc = c.Save();

            this.Degree = this.Degree % 360 + DEGREE_STEP;
            //Ҫ����ת����ͼ����Ч��
            c.Rotate(this.Degree, c.Width / 2, c.Height / 2);

            //���ĵ�
            var cx = c.Width / 2;
            var cy = c.Height / 2;

            //�޶���ʾ��Χ, ָ���뾶��Բ
            var path = new Path();
            path.AddCircle(cx, cy, this.BitmapRadius, Path.Direction.Cw);
            c.ClipPath(path);
            c.DrawColor(Color.White);

            //ͼƬ�Ļ��Ʒ�Χ
            var w = (this.ShowType == ShowTypes.Inner ? this.IWH : this.OWH) / 2;
            var rect = new Rect(cx - w, cy - w, cx + w, cy + w);

            //����ͼƬ
            var paint = new Paint();
            //srcΪnull, ��������ͼƬ��ΪԴ
            c.DrawBitmap(bmp, null, rect, paint);

            c.RestoreToCount(sc);
        }
 protected void onDraw(Canvas c)
 {
     c.Rotate (-90);
     c.Translate (-Height, 0);
     base.OnDraw (c);
 }
Esempio n. 26
0
            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;
                            }
                        }

                    }
                }
            }
Esempio n. 27
0
        private void DrawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds)
        {
            if (mShowArrow)
            {
                if (mArrow == null)
                {
                    mArrow = new Path();
                    mArrow.SetFillType(Path.FillType.EvenOdd);
                }
                else
                {
                    mArrow.Reset();
                }

                float x = (float)(RingCenterRadius * Math.Cos(0) + bounds.ExactCenterX());
                float y = (float)(RingCenterRadius * Math.Sin(0) + bounds.ExactCenterY());

                mArrow.MoveTo(0, 0);
                mArrow.LineTo((mArrowWidth) * mArrowScale, 0);
                mArrow.LineTo(((mArrowWidth) * mArrowScale / 2), (mArrowHeight * mArrowScale));
                mArrow.Offset(x - ((mArrowWidth) * mArrowScale / 2), y);
                mArrow.Close();

                mArrowPaint.Color = mColors[mColorIndex];
                c.Rotate(startAngle + (sweepAngle < 0 ? 0 : sweepAngle) - ARROW_OFFSET_ANGLE, bounds.ExactCenterX(), bounds.ExactCenterY());
                c.DrawPath(mArrow, mArrowPaint);
            }
        }
 public override void Draw(Canvas canvas)
 {
     Rect bounds = Bounds;
     int saveCount = canvas.Save();
     canvas.Rotate(mRotation, bounds.ExactCenterX(), bounds.ExactCenterY());
     mRing.Draw(canvas, bounds);
     canvas.RestoreToCount(saveCount);
 }
Esempio n. 29
0
			void DrawOval (Canvas canvas, float x, float y, float major, float minor,
				float orientation, Paint paint)
			{
				canvas.Save (SaveFlags.Matrix);
				canvas.Rotate ((float) (orientation * 180 / Math.PI), x, y);
				mReusableOvalRect.Left = x - minor / 2;
				mReusableOvalRect.Right = x + minor / 2;
				mReusableOvalRect.Top = y - major / 2;
				mReusableOvalRect.Bottom = y + major / 2;
				canvas.DrawOval (mReusableOvalRect, paint);
				canvas.Restore ();
			}
Esempio n. 30
0
        private void DrawRing(Canvas c)
        {
            var sc = c.Save();

            c.Rotate(-this.Degree, c.Width / 2, c.Height / 2);

            //���ĵ�
            var cx = c.Width / 2;
            var cy = c.Height / 2;

            //������Բ Path ����һ�� Բ����ʾ����, ���ڿ���Բ
            var pInner = new Path();
            pInner.AddCircle(cx, cy, this.BitmapRadius + SPACE / 2, Path.Direction.Cw);
            var pOut = new Path();
            pOut.AddCircle(cx, cy, this.Radius, Path.Direction.Cw);

            c.ClipPath(pOut);
            c.ClipPath(pInner, Region.Op.Difference);

            //var color = new Color((int)(DateTime.Now.Ticks % 0xFFFFFFFF));
            //c.DrawColor(color);

            //�ýǶȽ��������Բ�ķ�Χ
            var g = new SweepGradient(cx, cy, Color.Green, Color.Transparent);
            var paint = new Paint();
            paint.SetShader(g);
            c.DrawCircle(cx, cy, this.Radius, paint);

            c.RestoreToCount(sc);
        }
Esempio n. 31
0
        public void DrawMinutesHand(Canvas canvas)
        {
            canvas.Save();
            canvas.Rotate(_minutes * 6);
            
            var paint = new Paint
            {
                Color = new Color(206, 206, 206),
                StrokeWidth = 4
            };
            paint.SetStyle(Paint.Style.Stroke);

            canvas.DrawPath(_minuteHand, paint);
            canvas.Restore();
        }
 public void transformCanvas(Canvas canvas, float percentOpen)
 {
     mTrans.transformCanvas(canvas, percentOpen);
     float f = interp.GetInterpolation(percentOpen);
     canvas.Rotate((openedDeg - closedDeg) * f + closedDeg,
             px, py);
 }