• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Graphics.Paint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Android.Graphics.Paint的典型用法代码示例。如果您正苦于以下问题:C# Paint类的具体用法?C# Paint怎么用?C# Paint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Paint类属于Android.Graphics命名空间,在下文中一共展示了Paint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnDraw

 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);
 }
开发者ID:MahendrenGanesan,项目名称:samples,代码行数:7,代码来源:Circle.cs


示例2: Draw

        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            try
            {
                if (!feature.RenderedGeometry.ContainsKey(style)) feature.RenderedGeometry[style] = ToAndroidBitmap(feature.Geometry);
                var bitmap = (AndroidGraphics.Bitmap)feature.RenderedGeometry[style];
                
                var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                dest = new BoundingBox(
                    dest.MinX,
                    dest.MinY,
                    dest.MaxX,
                    dest.MaxY);

                var destination = RoundToPixel(dest);
                using (var paint = new Paint())
                {
                    canvas.DrawBitmap(bitmap, new Rect(0, 0, bitmap.Width, bitmap.Height), destination, paint);
                }

                DrawOutline(canvas, style, destination);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:28,代码来源:RasterRenderer.cs


示例3: getRoundedCroppedBitmap

		public static Bitmap getRoundedCroppedBitmap(Bitmap bitmap, int radius) {
			Bitmap finalBitmap;
			if (bitmap.Width != radius || bitmap.Height!= radius)
				finalBitmap = Bitmap.CreateScaledBitmap(bitmap, radius, radius,
					false);
			else
				finalBitmap = bitmap;
			Bitmap output = Bitmap.CreateBitmap(finalBitmap.Width,
				finalBitmap.Height, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas(output);

			 Paint paint = new Paint();
			Rect rect = new Rect(0, 0, finalBitmap.Width,
				finalBitmap.Height);

			paint.AntiAlias=true;
			paint.FilterBitmap=true;
			paint.Dither=true;
			canvas.DrawARGB(0, 0, 0, 0);
			paint.Color=Color.ParseColor("#BAB399");
			canvas.DrawCircle(finalBitmap.Width / 2 + 0.7f,
				finalBitmap.Height / 2 + 0.7f,
				finalBitmap.Width / 2 + 0.1f, paint);
			paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
			canvas.DrawBitmap(finalBitmap, rect, rect, paint);

			return output;
		}	
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:28,代码来源:RoundedImageView.cs


示例4: CirclePageIndicator

		public CirclePageIndicator(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
		{
			//Load defaults from resources
			var res = Resources;
			int defaultPageColor = res.GetColor(Resource.Color.default_circle_indicator_page_color);
			int defaultFillColor = res.GetColor(Resource.Color.default_circle_indicator_fill_color);
			int defaultOrientation = res.GetInteger(Resource.Integer.default_circle_indicator_orientation);
			int defaultStrokeColor = res.GetColor(Resource.Color.default_circle_indicator_stroke_color);
			float defaultStrokeWidth = res.GetDimension(Resource.Dimension.default_circle_indicator_stroke_width);
			float defaultRadius = res.GetDimension(Resource.Dimension.default_circle_indicator_radius);
			bool defaultCentered = res.GetBoolean(Resource.Boolean.default_circle_indicator_centered);
			bool defaultSnap = res.GetBoolean(Resource.Boolean.default_circle_indicator_snap);

			//Retrieve styles attributes
			var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.CirclePageIndicator, defStyle, Resource.Style.Widget_CirclePageIndicator);

			mCentered = a.GetBoolean(Resource.Styleable.CirclePageIndicator_vpiCentered, defaultCentered);
			mOrientation = a.GetInt(Resource.Styleable.CirclePageIndicator_vpiOrientation, defaultOrientation);
			mPaintPageFill = new Paint(PaintFlags.AntiAlias);
			mPaintPageFill.SetStyle(Paint.Style.Fill);
			mPaintPageFill.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_vpiPageColor, defaultPageColor);
			mPaintStroke = new Paint(PaintFlags.AntiAlias);
			mPaintStroke.SetStyle(Paint.Style.Stroke);
			mPaintFill = new Paint(PaintFlags.AntiAlias);
			mPaintFill.SetStyle(Paint.Style.Fill);
			mSnap = a.GetBoolean(Resource.Styleable.CirclePageIndicator_vpiSnap, defaultSnap);

			mRadius = a.GetDimension(Resource.Styleable.CirclePageIndicator_vpiRadius, defaultRadius);
			mPaintFill.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_vpiFillColor, defaultFillColor);
			mPaintStroke.Color = a.GetColor(Resource.Styleable.CirclePageIndicator_vpiStrokeColor, defaultStrokeColor);
			mPaintStroke.StrokeWidth = a.GetDimension(Resource.Styleable.CirclePageIndicator_vpiStrokeWidth, defaultStrokeWidth);

			a.Recycle();

		}
开发者ID:alexrainman,项目名称:CarouselView,代码行数:35,代码来源:CirclePageIndicator.cs


示例5: ToCropped

		public static Bitmap ToCropped(Bitmap source, double zoomFactor, double xOffset, double yOffset, double cropWidthRatio, double cropHeightRatio)
		{
			double sourceWidth = source.Width;
			double sourceHeight = source.Height;

			double desiredWidth = sourceWidth;
			double desiredHeight = sourceHeight;

			double desiredRatio = cropWidthRatio / cropHeightRatio;
			double currentRatio = sourceWidth / sourceHeight;

			if (currentRatio > desiredRatio)
				desiredWidth = (cropWidthRatio * sourceHeight / cropHeightRatio);
			else if (currentRatio < desiredRatio)
				desiredHeight = (cropHeightRatio * sourceWidth / cropWidthRatio);

			xOffset = xOffset * desiredWidth;
			yOffset = yOffset * desiredHeight;

			desiredWidth =  desiredWidth / zoomFactor;
			desiredHeight = desiredHeight / zoomFactor;

			float cropX = (float)(((sourceWidth - desiredWidth) / 2) + xOffset);
			float cropY = (float)(((sourceHeight - desiredHeight) / 2) + yOffset);

			if (cropX < 0)
				cropX = 0;

			if (cropY < 0)
				cropY = 0;

			if (cropX + desiredWidth > sourceWidth)
				cropX = (float)(sourceWidth - desiredWidth);

			if (cropY + desiredHeight > sourceHeight)
				cropY = (float)(sourceHeight - desiredHeight);

			Bitmap bitmap = Bitmap.CreateBitmap((int)desiredWidth, (int)desiredHeight, source.GetConfig());

			using (Canvas canvas = new Canvas(bitmap))
			using (Paint paint = new Paint())
			using (BitmapShader shader = new BitmapShader(source, Shader.TileMode.Clamp, Shader.TileMode.Clamp))
			using (Matrix matrix = new Matrix())
			{
				if (cropX != 0 || cropY != 0)
				{
					matrix.SetTranslate(-cropX, -cropY);
					shader.SetLocalMatrix(matrix);
				}

				paint.SetShader(shader);
				paint.AntiAlias = false;

				RectF rectF = new RectF(0, 0, (int)desiredWidth, (int)desiredHeight);
				canvas.DrawRect(rectF, paint);

				return bitmap;				
			}
		}
开发者ID:Sohojoe,项目名称:FFImageLoading,代码行数:59,代码来源:CropTransformation.cs


示例6: CircleDrawable

 public CircleDrawable(Bitmap bmp)
 {
     this.bmp = bmp;
     this.bmpShader = new BitmapShader(bmp, Shader.TileMode.Clamp, Shader.TileMode.Clamp);
     this.paint = new Paint() { AntiAlias = true };
     this.paint.SetShader(bmpShader);
     this.oval = new RectF();
 }
开发者ID:pmourfield,项目名称:xamarin-store-app,代码行数:8,代码来源:CircleDrawable.cs


示例7: DrawRectangle

 private static void DrawRectangle(Canvas canvas, RectF destination, Styles.Color outlineColor)
 {
     var paint = new Paint();
     paint.SetStyle(Paint.Style.Stroke);
     paint.Color = new AndroidColor(outlineColor.R, outlineColor.G, outlineColor.B, outlineColor.A);
     paint.StrokeWidth = 4;
     canvas.DrawRect(destination, paint);
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:8,代码来源:RasterRenderer.cs


示例8: CanvasRenderContext

 /// <summary>
 /// Initializes a new instance of the <see cref="CanvasRenderContext" /> class.
 /// </summary>
 /// <param name="scale">The scale.</param>
 public CanvasRenderContext(double scale)
 {
     this.paint = new Paint();
     this.path = new Path();
     this.bounds = new Rect();
     this.pts = new List<float>();
     this.Scale = scale;
 }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:12,代码来源:CanvasRenderContext.cs


示例9: Create

		public object Create(Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			var shader = new ag.LinearGradient(startPoint.X, startPoint.Y, endPoint.X, endPoint.Y, startColor.ToAndroid(), endColor.ToAndroid(), 
				// is this correct?
				ag.Shader.TileMode.Clamp);
			var paint = new ag.Paint();
			paint.SetShader(shader);
			return new BrushObject { Paint = paint }; // TODO: initial matrix
		}
开发者ID:mhusen,项目名称:Eto,代码行数:9,代码来源:LinearGradientBrushHandler.cs


示例10: InitStepCountPaint

			void InitStepCountPaint()
			{
				stepcountPaint = new Paint();
				//stepcountPaint.Color = Color.White;
				stepcountPaint.SetARGB(255, 50, 151, 218);
				stepcountPaint.SetTypeface(Typeface.Create(Typeface.SansSerif, TypefaceStyle.Normal));
				stepcountPaint.AntiAlias = true;
				stepcountPaint.TextSize = owner.Resources.GetDimension(Resource.Dimension.StepCountTextSize);
			}
开发者ID:chrisriesgo,项目名称:mini-hacks,代码行数:9,代码来源:XFitWatchfaceServiceStepCount.cs


示例11: KenBurnsDrawable

 public KenBurnsDrawable(Color defaultColor)
 {
     this.defaultColor = defaultColor;
     this.paint = new Paint
     {
         AntiAlias = false,
         FilterBitmap = false
     };
 }
开发者ID:pmourfield,项目名称:xamarin-store-app,代码行数:9,代码来源:KenBurnsDrawable.cs


示例12: ChartSurface

		/// <summary>
		/// Initializes a new instance of the <see cref="ChartSurface"/> class.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="chart">The chart.</param>
		/// <param name="color">The color.</param>
		/// <param name="colors">The colors.</param>
		public ChartSurface(Context context, Chart chart, AndroidColor color, AndroidColor[] colors)
			: base(context)
		{
			SetWillNotDraw(false);

			Chart = chart;
			Paint = new Paint() { Color = color, StrokeWidth = 2 };
			Colors = colors;
		}
开发者ID:jdluzen,项目名称:Xamarin-Forms-Labs,代码行数:16,代码来源:ChartSurface.cs


示例13: Create

		public object Create(Color color)
		{
			var result = new ag.Paint
			{
				Color = color.ToAndroid(),
			};
			result.SetStyle(ag.Paint.Style.Fill);
			return result;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:9,代码来源:SolidBrushHandler.cs


示例14: ApplyCustomTypeface

        private static void ApplyCustomTypeface(Paint paint, Typeface tf, TypefaceStyle style, int size)
        {
            if (style == TypefaceStyle.Italic)
                paint.TextSkewX = -0.25f;

            if(size > 0)
                paint.TextSize = size;

            paint.SetTypeface (tf);
        }
开发者ID:FrederickEskens,项目名称:Totem,代码行数:10,代码来源:CustomTypefaceSpan.cs


示例15: ShowPath

 private void ShowPath(Canvas canvas, int x, int y, Path.FillType ft, Paint paint)
 {
     canvas.Save();
     canvas.Translate(x, y);
     canvas.ClipRect(0, 0, 120, 120);
     canvas.DrawColor(Color.White);
     mPath.SetFillType(ft);
     canvas.DrawPath(mPath, paint);
     canvas.Restore();
 }
开发者ID:Cheesebaron,项目名称:MonoDroid.PathFillTypes,代码行数:10,代码来源:PathFillSampleView.cs


示例16: ConvertConfig

 public static Bitmap ConvertConfig(Bitmap bitmap, Bitmap.Config config)
 {
     if (bitmap.GetConfig().Equals(config))
         return Bitmap.CreateBitmap(bitmap);
     Bitmap convertedBitmap = Bitmap.CreateBitmap(bitmap.Width, bitmap.Height, config);
     Canvas canvas = new Canvas(convertedBitmap);
     Android.Graphics.Paint paint = new Android.Graphics.Paint();
     paint.Color = Android.Graphics.Color.Black;
     canvas.DrawBitmap(bitmap, 0, 0, paint);
     return convertedBitmap;
 }
开发者ID:kevincwq,项目名称:Cross.Drawing,代码行数:11,代码来源:BufferToBitmap.cs


示例17: Create

		public object Create(Color color, float thickness)
		{
			var paint = new ag.Paint 
			{ 
				Color = color.ToAndroid(), 
				StrokeWidth = thickness,
				StrokeCap = ag.Paint.Cap.Square,
				StrokeMiter = 10f
			};
			return paint;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:11,代码来源:PenHandler.cs


示例18: CircleView

        public CircleView(Context context, int width, int height, int offset): base(context)
        {
            var paint = new Paint();
            paint.Color = Color.Red;
            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeWidth = 3;

            _shape = new ShapeDrawable(new OvalShape());
            _shape.Paint.Set(paint);

            _shape.SetBounds(offset, offset, width-offset, height-offset);
        }
开发者ID:corneliu-serediuc,项目名称:Xamarin.Forms.KnobControl,代码行数:12,代码来源:CircleView.cs


示例19: Draw

        public override void Draw(Canvas canvas, ICharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
        {
            PrepView();

            canvas.Save();

            //Centering the token looks like a better strategy that aligning the bottom
            int padding = (bottom - top - View.Bottom) / 2;
            canvas.Translate(x, bottom - View.Bottom - padding);
            View.Draw(canvas);
            canvas.Restore();
        }
开发者ID:mattwhetton,项目名称:TokenCompleteTextView,代码行数:12,代码来源:ViewSpan.cs


示例20: Init

 private void Init()
 {
     IsRunning = false;
     OutlineAlpha = 1.0f;
     outlinePaint = new Paint();
     outlinePaint.AntiAlias = true;
     outlinePaint.StrokeWidth = Utils.Dp2Px(2);
     outlinePaint.Color = Resources.GetColor(Resource.Color.holo_blue);
     outlinePaint.SetStyle(Paint.Style.Stroke);
     var padding = Utils.Dp2Px(10);
     SetPadding(padding, padding, padding, padding);
 }
开发者ID:cyecp,项目名称:XamarinComponents,代码行数:12,代码来源:JazzyOutlineContainer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.Path类代码示例发布时间:2022-05-24
下一篇:
C# Graphics.Canvas类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap