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); }
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; } }
public new void Draw(Canvas canvas, Paint paint) { int viewWidth = mProgressBar.Width; int viewHeight = mProgressBar.Height; canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2 + mShadowRadius), mShadowPaint); canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2), paint); }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); _buttonBackgroundPaint.Color = _backgroundColor; float diameter = _radius * 2; float uWidth = PaddingLeft == 0 && PaddingRight == 0 ? diameter : Width - PaddingLeft - PaddingRight; float uHeight = PaddingBottom == 0 && PaddingTop == 0 ? diameter : Height - PaddingTop - PaddingBottom; float cx = uWidth / 2; float cy = uHeight / 2; float radius = Math.Min(uWidth - DipToPixels(2), uHeight - DipToPixels(2)) / 2; if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { SetLayerType(LayerType.Software, null); } _shadowPaint.SetShadowLayer(10, 0, 0, _shadowColor); canvas.DrawCircle(cx, cy, radius - 4, _shadowPaint); canvas.DrawCircle(cx, cy, radius, _buttonBackgroundPaint); int sidePadding = (int)(_radius * 0.25); int ulPadding = (int)(_radius * (0.25 + _contentScale)); _drawableContent?.SetBounds(sidePadding, sidePadding, ulPadding, ulPadding); _drawableContent?.Draw(canvas); }
protected override void Draw(Canvas canvas, Rect bounds) { int saveCount = canvas.Save(); for (int i = 0; i < mBallCount; i++) { if (i == mSwapIndex) { mPaint.SetStyle(Paint.Style.Fill); canvas.DrawCircle(mBallSideOffsets + mBallRadius * (i * 2 + 1) + i * mBallInterval + mSwapBallOffsetX, mBallCenterY - mSwapBallOffsetY, mBallRadius, mPaint); } else if (i == (mSwapIndex + 1) % mBallCount) { mPaint.SetStyle(Paint.Style.Stroke); canvas.DrawCircle(mBallSideOffsets + mBallRadius * (i * 2 + 1) + i * mBallInterval - mSwapBallOffsetX, mBallCenterY + mSwapBallOffsetY, mBallRadius - mStrokeWidth / 2, mPaint); } else { mPaint.SetStyle(Paint.Style.Stroke); canvas.DrawCircle(mBallSideOffsets + mBallRadius * (i * 2 + 1) + i * mBallInterval, mBallCenterY, mBallRadius - mStrokeWidth / 2, mPaint); } } canvas.RestoreToCount(saveCount); }
protected override void Draw(Canvas canvas, Rect bounds) { int saveCount = canvas.Save(); for (int i = 1; i < mBallCount - 1; i++) { mPaint.Alpha = MAX_ALPHA; canvas.DrawCircle(mBallRadius * (i * 2 - 1) + mBallSideOffsets, mBallCenterY, mBallRadius, mPaint); mOvalRect.Set(mBallRadius * (i * 2 - 2) + mBallSideOffsets, Height - mOvalVerticalRadius * 2, mBallRadius * (i * 2) + mBallSideOffsets, Height); mPaint.Alpha = OVAL_ALPHA; canvas.DrawOval(mOvalRect, mPaint); } //draw the first ball mPaint.Alpha = MAX_ALPHA; canvas.DrawCircle(mBallSideOffsets - mBallRadius - mLeftBallMoveXOffsets, mBallCenterY - mLeftBallMoveYOffsets, mBallRadius, mPaint); mOvalRect.Set(mBallSideOffsets - mBallRadius - mBallRadius * mLeftOvalShapeRate - mLeftBallMoveXOffsets, Height - mOvalVerticalRadius - mOvalVerticalRadius * mLeftOvalShapeRate, mBallSideOffsets - mBallRadius + mBallRadius * mLeftOvalShapeRate - mLeftBallMoveXOffsets, Height - mOvalVerticalRadius + mOvalVerticalRadius * mLeftOvalShapeRate); mPaint.Alpha = OVAL_ALPHA; canvas.DrawOval(mOvalRect, mPaint); //draw the last ball mPaint.Alpha = MAX_ALPHA; canvas.DrawCircle(mBallRadius * (mBallCount * 2 - 3) + mBallSideOffsets + mRightBallMoveXOffsets, mBallCenterY - mRightBallMoveYOffsets, mBallRadius, mPaint); mOvalRect.Set(mBallRadius * (mBallCount * 2 - 3) - mBallRadius * mRightOvalShapeRate + mBallSideOffsets + mRightBallMoveXOffsets, Height - mOvalVerticalRadius - mOvalVerticalRadius * mRightOvalShapeRate, mBallRadius * (mBallCount * 2 - 3) + mBallRadius * mRightOvalShapeRate + mBallSideOffsets + mRightBallMoveXOffsets, Height - mOvalVerticalRadius + mOvalVerticalRadius * mRightOvalShapeRate); mPaint.Alpha = OVAL_ALPHA; canvas.DrawOval(mOvalRect, mPaint); canvas.RestoreToCount(saveCount); }
public override void OnDrawItemIcon(Android.Graphics.Canvas canvas, PoiViewItem item, float startX, float endY) { int circleSize = 42; canvas.DrawCircle(startX, ToPixels(circleSize), ToPixels(circleSize), paintBlack); canvas.DrawCircle(startX, ToPixels(circleSize), ToPixels(circleSize - 3), item.Selected ? paintWhite : paintGray); var bmp = poiCategoryBitmapProvider.GetCategoryIcon(item.Poi.Category); canvas.DrawBitmap(bmp, startX - ToPixels(33), ToPixels(circleSize - 33), null /*ColorFilterPoiItem.GetPaintFilter(item)*/); }
protected override void OnDraw(Android.Graphics.Canvas canvas) { var radius = (Height / 2) - 4; var middleX = Width / 2; var middleY = Height / 2; var minutes = (int)time.TotalMinutes; var rotation = minutes / 60; var color = baseQuadrantColor; for (int i = 0; i <= rotation; i++) { var angle = minutes > 60 ? 360 : (int)((minutes * 360f) / 60); canvas.DrawArc(new RectF(middleX - radius, middleY - radius, middleX + radius, middleY + radius), -90, angle, true, new Paint { Color = color, AntiAlias = true, }); minutes -= 60; color = Color.Rgb((byte)Math.Max(0, color.R - 30), (byte)Math.Max(0, color.G - 30), (byte)Math.Max(0, color.B - 30)); } // Draw chrome Paint chromeBorder = new Paint { AntiAlias = true, Color = chromeColor, StrokeWidth = 1.ToPixels () }; chromeBorder.SetStyle(Paint.Style.Stroke); canvas.DrawCircle(middleX, middleY, radius, chromeBorder); // Draw markers var markerPaint = new Paint { Color = chromeColor, AntiAlias = true }; var innerRadius = radius - 6; for (int i = 0; i < 8; i++) { var stepAngle = i * Math.PI / 4; canvas.DrawCircle(middleX - (int)Math.Round(Math.Sin(stepAngle) * innerRadius), middleY - (int)Math.Round(Math.Cos(stepAngle) * innerRadius), 1, markerPaint); } }
protected override void OnDraw (Canvas canvas) { canvas.DrawColor (Color.White); canvas.Translate (10, 10); canvas.SaveLayerAlpha (0, 0, 200, 200, 0x88, SaveFlags.All); mPaint.Color = Color.Red; canvas.DrawCircle (75, 75, 75, mPaint); mPaint.Color = Color.Blue; canvas.DrawCircle (125, 125, 75, mPaint); canvas.Restore (); }
public Bitmap Transform(Bitmap source) { int size = Math.Min(source.Width, source.Height); int width = (source.Width - size) / 2; int height = (source.Height - size) / 2; var bitmap = Bitmap.CreateBitmap(size, size, Bitmap.Config.Argb4444); var canvas = new Canvas(bitmap); var paint = new Paint(); var shader = new BitmapShader(source, BitmapShader.TileMode.Clamp, BitmapShader.TileMode.Clamp); if (width != 0 || height != 0) { // source isn't square, move viewport to center var matrix = new Matrix(); matrix.SetTranslate(-width, -height); shader.SetLocalMatrix(matrix); } paint.SetShader(shader); paint.AntiAlias = true; float r = size / 2f; canvas.DrawCircle(r, r, r, paint); source.Recycle(); return bitmap; }
protected override void OnDraw(Canvas canvas) { Drawable drawable = this.Drawable; if (drawable == null) { return; } if (this.Width == 0 || this.Height == 0) { return; } if (paint == null) { Init (); } int circleCenter = Width / 2; // circleCenter is the x or y of the view's center // radius is the radius in pixels of the cirle to be drawn // paint contains the shader that will texture the shape canvas.DrawCircle (circleCenter, circleCenter, circleCenter, paint); }
protected override Bitmap Transform(IBitmapPool bitmapPool, Bitmap source, int outWidth, int outHeight) { int size = Math.Min(source.Width, source.Height); int width = (source.Width - size) / 2; int height = (source.Height - size) / 2; Bitmap squaredBitmap = Bitmap.CreateBitmap(source, width, height, size, size); if (squaredBitmap != source) { source.Recycle(); } Bitmap bitmap = Bitmap.CreateBitmap(size, size, Bitmap.Config.Argb8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.Clamp, BitmapShader.TileMode.Clamp); paint.SetShader(shader); paint.AntiAlias = true; float r = size / 2f; canvas.DrawCircle(r, r, r, paint); squaredBitmap.Recycle(); return BitmapResource.Obtain(bitmap, bitmapPool).Get(); }
protected void DrawShape(Canvas canvas) { Paint paint = new Paint(); paint.Color = Color; switch (Shape) { case ShapeEnum.RectangleShape: canvas.DrawRect(0, 0, ShapeWidth, ShapeHeight, paint); break; case ShapeEnum.OvalShape: canvas.DrawOval(new RectF(0, 0, ShapeWidth, ShapeHeight), paint); break; case ShapeEnum.TriangleShape: Path path = new Path(); path.MoveTo(ShapeWidth / 2, 0); path.LineTo(ShapeWidth, ShapeHeight); path.LineTo(0,ShapeHeight); path.Close(); canvas.DrawPath(path, paint); break; default: canvas.DrawCircle(ShapeWidth / 2, ShapeHeight / 2, ShapeWidth / 2, paint); break; } }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var paint = new Paint(); paint.SetColor(Color); canvas.DrawCircle(Width / 2, Height / 2, Width / 2, paint); }
private void DrawStroke(Canvas canvas) { var stroke = Stroke; if (!HasStroke || stroke is ImageBrush) { return; } var strokeThickness = PhysicalStrokeThickness; using (var strokePaint = new Paint(stroke.GetStrokePaint(_drawArea))) { SetStrokeDashEffect(strokePaint); if (_drawArea.HasZeroArea()) { //Draw the stroke as a fill because the shape has no area strokePaint.SetStyle(Paint.Style.Fill); canvas.DrawCircle((float)(strokeThickness / 2), (float)(strokeThickness / 2), (float)(strokeThickness / 2), strokePaint); } else { strokePaint.StrokeWidth = (float)strokeThickness; canvas.DrawPath(_path, strokePaint); } } }
static Bitmap GetCroppedBitmap (Bitmap bmp, int radius) { Bitmap sbmp; if (bmp.Width != radius || bmp.Height != radius) sbmp = Bitmap.CreateScaledBitmap (bmp, radius, radius, false); else sbmp = bmp; var output = Bitmap.CreateBitmap (sbmp.Width, sbmp.Height, Bitmap.Config.Argb8888); var canvas = new Canvas (output); var paint = new Paint (); var rect = new Rect (0, 0, sbmp.Width, sbmp.Height); paint.AntiAlias = true; paint.FilterBitmap = true; paint.Dither = true; canvas.DrawARGB (0, 0, 0, 0); paint.Color = Color.ParseColor ("#BAB399"); canvas.DrawCircle (sbmp.Width / 2 + 0.7f, sbmp.Height / 2 + 0.7f, sbmp.Width / 2 + 0.1f, paint); paint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.SrcIn)); canvas.DrawBitmap (sbmp, rect, rect, paint); return output; }
internal void Draw(Canvas canvas) { canvas.DrawCircle(_cells.Last().X, _cells.Last().Y, 3, this); for (int p = _cells.Count - 1; p > 0; p--) { canvas.DrawLine(_cells[p].X, _cells[p].Y, _cells[p - 1].X, _cells[p - 1].Y, this); } }
public void DrawMask(View target, Canvas maskCanvas, Color maskColor, Point position, int radius, Animator animator) { // draw solid background maskCanvas.DrawColor(maskColor); // erase focus area maskCanvas.DrawCircle(position.X, position.Y, radius, eraserPaint); }
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); HandleStandardDraw(canvas, p => canvas.DrawCircle(x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p)); }
protected override void OnDraw(Canvas canvas) { var paint = new Paint(); paint.SetARGB(255, 200, 255, 0); paint.SetStyle(Paint.Style.Stroke); paint.StrokeWidth = 4; canvas.DrawCircle (200, 200, 180, paint); }
protected override void Draw(Canvas canvas, Rect bounds) { RectF arcBounds = mTempBounds; arcBounds.Set(bounds); arcBounds.Inset(mStrokeInset, mStrokeInset); mCurrentBounds.Set(arcBounds); int saveCount = canvas.Save(); //draw circle trim float startAngle = (mStartTrim + mRotation) * 360; float endAngle = (mEndTrim + mRotation) * 360; float sweepAngle = endAngle - startAngle; if (sweepAngle != 0) { mPaint.Color = new Color(mColor); mPaint.SetStyle(Paint.Style.Stroke); canvas.DrawArc(arcBounds, startAngle, sweepAngle, false, mPaint); } //draw water wave if (mWaveProgress < 1.0f) { var nColor = new Color(mColor); mPaint.Color = Color.Argb((int)(Color.GetAlphaComponent(mColor) * (1.0f - mWaveProgress)), Color.GetRedComponent(mColor), Color.GetGreenComponent(mColor), Color.GetBlueComponent(mColor)); mPaint.SetStyle(Paint.Style.Stroke); float radius = Math.Min(arcBounds.Width(), arcBounds.Height()) / 2.0f; canvas.DrawCircle(arcBounds.CenterX(), arcBounds.CenterY(), radius * (1.0f + mWaveProgress), mPaint); } //draw ball bounce if (mPathMeasure != null) { mPaint.Color = new Color(mBallColor); mPaint.SetStyle(Paint.Style.Fill); canvas.DrawCircle(mCurrentPosition[0], mCurrentPosition[1], mSkipBallSize * mScale, mPaint); } canvas.RestoreToCount(saveCount); }
public void DrawMask(View target, Canvas maskCanvas, Color maskColor, Point position, int radius, Animator animator) { var valueAnimator = animator as ValueAnimator; var bounce = valueAnimator != null ? (float)valueAnimator.AnimatedValue : target.Alpha; // draw solid background maskCanvas.DrawColor(maskColor); // erase focus area maskCanvas.DrawCircle(position.X, position.Y, radius * bouncy.GetInterpolation(bounce), eraserPaint); }
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); }
public static void Parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint) { float? centerX = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_X); float? centerY = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_CENTER_Y); float? radius = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_RADIUS); if (centerX != null && centerY != null && radius != null) { bool fill = pSVGPaint.setFill(pSVGProperties); if (fill) { pCanvas.DrawCircle(centerX.Value, centerY.Value, radius.Value, pSVGPaint.getPaint()); } bool stroke = pSVGPaint.setStroke(pSVGProperties); if (stroke) { pCanvas.DrawCircle(centerX.Value, centerY.Value, radius.Value, pSVGPaint.getPaint()); } if(fill || stroke) { pSVGPaint.ensureComputedBoundsInclude(centerX.Value - radius.Value, centerY.Value - radius.Value); pSVGPaint.ensureComputedBoundsInclude(centerX.Value + radius.Value, centerY.Value + radius.Value); } } }
public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature) { var point = feature.Geometry as Point; var dest = viewport.WorldToScreen(point); var symbolSize = (float)SymbolStyle.DefaultHeight; var symbolType = SymbolType.Ellipse; var symbolStyle = style as SymbolStyle; if (symbolStyle != null) { if (symbolStyle.BitmapId >= 0) { // Bitmap if (!feature.RenderedGeometry.ContainsKey(style)) { var imageStream = BitmapRegistry.Instance.Get(symbolStyle.BitmapId); imageStream.Position = 0; var androidBitmap = BitmapFactory.DecodeStream(imageStream); feature.RenderedGeometry[style] = androidBitmap; } var bitmap = (Bitmap)feature.RenderedGeometry[style]; var halfWidth = bitmap.Width / 2; var halfHeight = bitmap.Height / 2; var dstRectForRender = new RectF((float)dest.X - halfWidth, (float)dest.Y - halfHeight, (float)dest.X + halfWidth, (float)dest.Y + halfHeight); canvas.DrawBitmap(bitmap, null, dstRectForRender, null); return; } symbolType = symbolStyle.SymbolType; if (symbolStyle.SymbolScale > 0) symbolSize = (float)symbolStyle.SymbolScale * symbolSize; } // Drawing var paints = style.ToAndroid(); if (symbolType == SymbolType.Ellipse) { foreach (var paint in paints) { canvas.DrawCircle((int)dest.X, (int)dest.Y, symbolSize, paint); paint.Dispose(); } } else { foreach (var paint in paints) { canvas.DrawRect(-(float)SymbolStyle.DefaultWidth, (float)SymbolStyle.DefaultHeight, (float)SymbolStyle.DefaultWidth, -(float)SymbolStyle.DefaultHeight, paint); paint.Dispose(); } } }
public override void Draw(Android.Graphics.Canvas canvas) { canvas.DrawCircle(mainCenter, mainCenter + 2, radius + radiusBorder, shadowPaint); canvas.DrawCircle(mainCenter, mainCenter, radius + radiusBorder, darkerBackPaint); canvas.DrawCircle(mainCenter, mainCenter, radius, backPaint); canvas.DrawBitmap(icon, mainCenter - icon.Width / 2, mainCenter - icon.Height / 2, imgPaint); if (Count != 0) { int bubbleCenter = center - removeRadius - bubbleOffset; greenPaint.Alpha = redPaint.Alpha = currentBubbleTransparency; removePaint.Alpha = 255 - currentBubbleTransparency; canvas.DrawCircle(bubbleCenter, bubbleCenter, removeRadius, removePaint); canvas.DrawCircle(bubbleCenter, bubbleCenter, innerRadius, Count < 0 ? redPaint : greenPaint); var c = Math.Abs(Count).ToString(); var textBounds = new Rect(); removePaint.GetTextBounds(c, 0, c.Length, textBounds); canvas.DrawText(c, bubbleCenter, bubbleCenter + textBounds.Height() / 2, removePaint); } DrawingCacheEnabled = true; }
protected override void OnDraw(Android.Graphics.Canvas canvas) { base.OnDraw(canvas); int x = kOuterPaddingHorizontal; int y = (this.Height / 2); for (int i = 0; i < Count; i++) { int radius = i == iSelectedIndex ? kSelectedRadius : kDeselectedRadius; x += radius; canvas.DrawCircle(x, y, radius, i == iSelectedIndex ? iPaintSelected : iPaintUnselected); x += radius + kInterItemPadding; } }
protected override void OnDraw(Canvas canvas) { int mBorderWidth; int mCanvasSize; Bitmap mImage; Paint mPaint; Paint mPaintBorder; mPaint = new Paint(); mPaint.AntiAlias = true; mPaintBorder = new Paint(); mPaintBorder.Color = BorderColor; mPaint.AntiAlias = true; mImage = DrawableToBitmap(Drawable); mBorderWidth = 2; if (mImage != null) { mCanvasSize = canvas.Width; if (canvas.Height < mCanvasSize) { mCanvasSize = canvas.Height; } Bitmap scaledBitmap = Bitmap.CreateScaledBitmap(mImage, mCanvasSize, mCanvasSize, true); //true --> apply the given scaleType. BitmapShader shader = new BitmapShader(scaledBitmap, Shader.TileMode.Clamp, Shader.TileMode.Clamp); mPaint.SetShader(shader); int circleCenter = (mCanvasSize - (mBorderWidth * 2)) / 2; if (ImageBorderVisibility) canvas.DrawCircle(circleCenter + mBorderWidth, circleCenter + mBorderWidth, ((mCanvasSize - (mBorderWidth * 2)) / 2) + mBorderWidth - 4.0f, mPaintBorder); canvas.DrawCircle(circleCenter + mBorderWidth, circleCenter + mBorderWidth, ((mCanvasSize - (mBorderWidth * 2)) / 2) - 4.0f, mPaint); } }
protected override void OnDraw(Canvas canvas) { var r = CenterX - _paint.StrokeWidth * 0.5f; canvas.Translate(CenterX, CenterX); canvas.DrawOval(new RectF(-r, -r, r, r), _paint); canvas.DrawCircle(0, 0, CenterRadius, _centerPaint); if (_trackingCenter) { var c = _centerPaint.Color; _centerPaint.SetStyle(Paint.Style.Stroke); _centerPaint.Alpha = _highlightCenter ? 255 : 128; canvas.DrawCircle(0, 0, CenterRadius + _centerPaint.StrokeWidth, _centerPaint); _centerPaint.SetStyle(Paint.Style.Fill); _centerPaint.Color = c; } }
public override void Draw(Android.Graphics.Canvas canvas, MapView mapView, bool shadow) { base.Draw(canvas, mapView, shadow); var paint = new Paint(); paint.AntiAlias = true; paint.Color = Color.Purple; paint.Alpha = 127; var gp = new GeoPoint((int)(29.97611 * 1e6), (int)(31.132778 * 1e6)); var pt = mapView.Projection.ToPixels(gp, null); float distance = mapView.Projection.MetersToEquatorPixels(200); canvas.DrawCircle(pt.X, pt.Y, distance / 2, paint); }
private void DoDraw(Canvas canvas, double stepFactor) { double width = canvas.GetWidth(); double height = canvas.GetHeight(); double x = width/2; double y = height/2; x += xOrientation * stepFactor; y += yOrientation * stepFactor; // Set background color canvas.DrawColor(Color.BLUE); var paint = new Paint(); paint.TextAlign =(Paint.Align.CENTER); // Draw a circle paint.Color =(Color.ParseColor("#ffd700")); canvas.DrawCircle((float) x, (float) y, 30, paint); }
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 void DrawStroke(Android.Graphics.Canvas canvas, Windows.Foundation.Rect strokeArea, Action <Android.Graphics.Canvas, Windows.Foundation.Rect, Paint> drawingMethod) { if (HasStroke) { var strokeThickness = PhysicalStrokeThickness; using (var strokePaint = new Paint(Stroke.GetStrokePaint(strokeArea))) { SetStrokeDashEffect(strokePaint); if (strokeArea.HasZeroArea()) { //Draw the stroke as a fill because the shape has no area strokePaint.SetStyle(Paint.Style.Fill); canvas.DrawCircle((float)(strokeThickness / 2), (float)(strokeThickness / 2), (float)(strokeThickness / 2), strokePaint); } else { strokePaint.StrokeWidth = (float)strokeThickness; drawingMethod(canvas, strokeArea, strokePaint); } } } }
protected override void OnDraw(Canvas canvas) { base.OnDraw (canvas); if (mViewPager == null) { return; } int count = mViewPager.Adapter.Count; if (count == 0) { return; } if (mCurrentPage >= count) { SetCurrentItem(count - 1); return; } int longSize; int longPaddingBefore; int longPaddingAfter; int shortPaddingBefore; if (mOrientation == HORIZONTAL) { longSize = Width; longPaddingBefore = PaddingLeft; longPaddingAfter = PaddingRight; shortPaddingBefore = PaddingTop; } else { longSize = Height; longPaddingBefore = PaddingTop; longPaddingAfter = PaddingBottom; shortPaddingBefore = PaddingLeft; } float threeRadius = mRadius * 3; float shortOffset = shortPaddingBefore + mRadius; float longOffset = longPaddingBefore + mRadius; if (mCentered) { longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * threeRadius) / 2.0f); } float dX; float dY; float pageFillRadius = mRadius; if (mPaintStroke.StrokeWidth > 0) { pageFillRadius -= mPaintStroke.StrokeWidth / 2.0f; } //Draw stroked circles for (int iLoop = 0; iLoop < count; iLoop++) { float drawLong = longOffset + (iLoop * threeRadius); if (mOrientation == HORIZONTAL) { dX = drawLong; dY = shortOffset; } else { dX = shortOffset; dY = drawLong; } // Only paint fill if not completely transparent if (mPaintPageFill.Alpha > 0) { canvas.DrawCircle(dX, dY, pageFillRadius, mPaintPageFill); } // Only paint stroke if a stroke width was non-zero if (pageFillRadius != mRadius) { canvas.DrawCircle(dX, dY, mRadius, mPaintStroke); } } //Draw the filled circle according to the current scroll float cx = (mSnap ? mSnapPage : mCurrentPage) * threeRadius; if (!mSnap && (mPageSize != 0)) { cx += (mCurrentOffset * 1.0f / mPageSize) * threeRadius; } if (mOrientation == HORIZONTAL) { dX = longOffset + cx; dY = shortOffset; } else { dX = shortOffset; dY = longOffset + cx; } canvas.DrawCircle(dX, dY, mRadius, mPaintFill); }
protected override void OnDraw(Canvas canvas) { // Don't draw anything without an image if (_image == null) return; // Nothing to draw (Empty bounds) if (_image.Height == 0 || _image.Width == 0) return; // We'll need this later int oldCanvasSize = _canvasSize; // Compare canvas sizes _canvasSize = canvas.Width; if (canvas.Height < _canvasSize) _canvasSize = canvas.Height; // Reinitialize shader, if necessary if (oldCanvasSize != _canvasSize) RefreshBitmapShader(); // Apply shader to paint _paint.SetShader(_shader); // Keep track of selectorStroke/border width int outerWidth = 0; // Get the exact X/Y axis of the view int center = _canvasSize / 2; if (_hasSelector && _isSelected) { // Draw the selector stroke & apply the selector filter, if applicable outerWidth = _selectorStrokeWidth; center = (_canvasSize - (outerWidth * 2)) / 2; _paint.SetColorFilter(_selectorFilter); canvas.DrawCircle(center + outerWidth, center + outerWidth, ((_canvasSize - (outerWidth * 2)) / 2) + outerWidth - 4.0f, _paintSelectorBorder); } else if (_hasBorder) { // If no selector was drawn, draw a border and clear the filter instead... if enabled outerWidth = _borderWidth; center = (_canvasSize - (outerWidth * 2)) / 2; _paint.SetColorFilter(null); canvas.DrawCircle(center + outerWidth, center + outerWidth, ((_canvasSize - (outerWidth * 2)) / 2) + outerWidth - 4.0f, _paintBorder); } else // Clear the color filter if no selector nor border were drawn _paint.SetColorFilter(null); // Draw the circular image itself canvas.DrawCircle(center + outerWidth, center + outerWidth, ((_canvasSize - (outerWidth * 2)) / 2) - 4.0f, _paint); }
private void DoDraw(Canvas canvas) { // Increment / reset size += delta; if (size > 250) { delta = -1; } else if (size < 30) { delta = 1; } // Set background color canvas.DrawColor(Color.BLUE); var paint = new Paint(); paint.TextAlign =(Paint.Align.CENTER); // Draw some lines canvas.DrawLine(mX, mY, mY + 33, mX + 100, paint); paint.Color =(Color.RED); paint.StrokeWidth = (10); canvas.DrawLine(87, 0, 75, 100, paint); paint.Color =(Color.GREEN); paint.StrokeWidth = (5); for (int y = 30, alpha = 128; alpha > 2; alpha >>= 1, y += 10) { paint.Alpha = (alpha); canvas.DrawLine(mY, y, mY + 100, y, paint); } // Draw a red rectangle paint.Color =(Color.RED); var rect = new Rect(); rect.Set(size + 120, 130, size + 156, 156); canvas.DrawRect(rect, paint); // Draw a circle paint.Color =(Color.ParseColor("#ffd700")); canvas.DrawCircle(size * 2, 220, 30, paint); //faster circle // Draw red'ish rectangle paint.Color =(Color.Rgb(128, 20, 20)); canvas.DrawRect(size, 67, 68, 45, paint); // Draw green circle paint.Color =(Color.GREEN); canvas.DrawCircle(size, 140.0f - size / 3, 45.0f, paint); //move circle across screen paint.Color =(Color.RED); canvas.DrawText("Dot42", size, 140.0f - size / 3, paint); // Draw magenta circle paint.Color =(Color.MAGENTA); canvas.DrawCircle(mX, mY, size / 4.0f, paint); //move circle down screen paint.Color =(Color.GREEN); canvas.DrawText("is", mX, mY, paint); // Draw yellow rectangle paint.Alpha = (64); paint.Color =(Color.YELLOW); canvas.DrawRect(size, size, size + 45, size + 45, paint); // Draw text on rectangle paint.Alpha = (255); paint.Color =(Color.DKGRAY); canvas.DrawText("fun!", size + 45 / 2, size + 45 / 2, paint); }
protected override void OnDraw(Canvas canvas) { // load the bitmap image = drawableToBitmap(Drawable); // init shader if (image != null) { canvasSize = canvas.Width; if (canvas.Height < canvasSize) { canvasSize = canvas.Height; } BitmapShader shader = new BitmapShader(Bitmap.CreateScaledBitmap(image, canvasSize, canvasSize, false), Shader.TileMode.Clamp, Shader.TileMode.Clamp); paint.SetShader(shader); int circleCenter = (canvasSize - (borderWidth * 2)) / 2; canvas.DrawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) + borderWidth - 4.0f, paintBorder); canvas.DrawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) - 4.0f, paint); } }
public void Draw(Android.Graphics.Canvas canvas) { canvas.DrawCircle(Current_X, Current_Y, diameter, line); canvas.DrawCircle(Current_X, Current_Y, diameter, fill); }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); if(null == _viewPager) return; var count = _viewPager.Adapter.Count; if(0 == count) return; if(_currentPage >= count) { CurrentItem = count - 1; return; } int longSize; int longPaddingBefore; int longPaddingAfter; int shortPaddingBefore; if(_orientation == (int)Orientation.Horizontal) { longSize = Width; longPaddingBefore = PaddingLeft; longPaddingAfter = PaddingRight; shortPaddingBefore = PaddingTop; } else { longSize = Height; longPaddingBefore = PaddingTop; longPaddingAfter = PaddingBottom; shortPaddingBefore = PaddingLeft; } var threeRadius = _radius * 3; var shortOffset = shortPaddingBefore + _radius; var longOffset = longPaddingBefore + _radius; if(_centered) longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * threeRadius) / 2.0f); float dX; float dY; var pageFillRadius = _radius; if(_paintStroke.StrokeWidth > 0) pageFillRadius -= _paintStroke.StrokeWidth / 2.0f; //Draw stroked circles for(var iLoop = 0; iLoop < count; iLoop++) { var drawLong = longOffset + (iLoop * threeRadius); if(_orientation == (int)Orientation.Horizontal) { dX = drawLong; dY = shortOffset; } else { dX = shortOffset; dY = drawLong; } //Only paint fill if not completely transparent if (_paintPageFill.Alpha > 0) canvas.DrawCircle(dX, dY, pageFillRadius, _paintPageFill); //Only paint stroke if a stroke width was non-zero if(pageFillRadius != _radius) canvas.DrawCircle(dX, dY, _radius, _paintStroke); } //Draw the filled circle according to the current scroll var cx = (_snap ? _snapPage : _currentPage) * threeRadius; if(_snap) cx += _pageOffset * threeRadius; if(_orientation == (int)Orientation.Horizontal) { dX = longOffset + cx; dY = shortOffset; } else { dX = shortOffset; dY = longOffset + cx; } canvas.DrawCircle(dX, dY, _radius, _paintFill); }
private void DrawIntoBitmap(Bitmap bm) { float x = bm.Width; float y = bm.Height; Canvas c = new Canvas (bm); Paint p = new Paint (); p.AntiAlias = true; p.Alpha = 0x80; c.DrawCircle (x / 2, y / 2, x / 2, p); p.Alpha = 0x30; p.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.Src)); p.TextSize = 60; p.TextAlign = Paint.Align.Center; Paint.FontMetrics fm = p.GetFontMetrics (); c.DrawText ("Alpha", x / 2, (y - fm.Ascent) / 2, p); }
private void DrawCenter(Canvas c) { var x = c.Width / 2; var y = c.Height / 2; var paint = new Paint() { Color = Color.White, AntiAlias = true }; //���Խ��� //var g = new LinearGradient(x - 30, y - 30, x + 30, y + 30, Color.Red, Color.Blue, Shader.TileMode.Mirror); // �ǶȽ��� // ��һ��,�ڶ���������ʾ����Բ�������� //var g = new SweepGradient(x, y, Color.Red, Color.Blue); //���ν��� //��һ��,�ڶ���������ʾ����Բ��������,������������ʾ�뾶 var g = new RadialGradient(x, y, 60, Color.Red, Color.Purple, Shader.TileMode.Mirror); paint.SetShader(g); c.DrawCircle(x, y, 60, paint); paint.Color = Color.Green; c.DrawCircle(x, y, 50, paint); }
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); }
protected override void OnDraw(Canvas canvas) { try { var radius = Math.Min(Width, Height) / 2; using (var paint1 = new Paint()) using (var paint2 = new Paint()) { paint1.Color = Android.Graphics.Color.Transparent; canvas.DrawRect(0, 0, this.Width, this.Height, paint1); paint2.Color = this.Element.Color.ToAndroid(); canvas.DrawCircle(Width / 2, Height / 2, radius, paint2); } } catch { //Debug.WriteLine("Unable to create circle image: " + ex); } base.OnDraw(canvas); }