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

C# Paint类代码示例

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

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



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

示例1: DrawEllipse

      // assumptions for pixel snapping: 
      // - the drawing context itself is pixel snapped
      // - all strokes have same thickness
      // - the thickness is a whole number


      #region ELLIPSES
      /// <summary>See <c>WpfExtensions</c> for details.</summary>
      public static void DrawEllipse(DrawingContext dc, Paint paint, Point center, double radiusX, double radiusY, bool snapToPixel) {
         // get brush and stroke resources
         if (paint == null) return;
         var fill = paint.Fill;
         var hasFill = (fill != null);
         var strokes = paint.GetStrokePens().ToArray();
         var numStrokes = strokes.Length;
         if (!hasFill && numStrokes == 0) return;

         var halfThickness = Math.Round(numStrokes > 0? strokes[0].Thickness : 0.0) / 2;
         if (snapToPixel) {
            center = new Point(center.X + halfThickness, center.Y + halfThickness);
         }

         if (numStrokes > 0) {
            for (var i = 0; i < numStrokes - 1; i++) {
               dc.DrawEllipse(null, strokes[i], center, radiusX, radiusY);
               radiusX = (radiusX - 2 * halfThickness).Max(0);
               radiusY = (radiusY - 2 * halfThickness).Max(0);
            }
            dc.DrawEllipse(fill, strokes[numStrokes - 1], center, radiusX, radiusY);
         } else {
            dc.DrawEllipse(fill, null, center, radiusX, radiusY);
         }

      }
开发者ID:borkaborka,项目名称:gmit,代码行数:34,代码来源:DrawingUtilities.cs


示例2: SlidingTabStrip1

        public SlidingTabStrip1(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            SetWillNotDraw(false);

            float density = Resources.DisplayMetrics.Density;

            TypedValue outValue = new TypedValue();
            context.Theme.ResolveAttribute(Android.Resource.Attribute.ColorForeground, outValue, true);
            int themeForeGround = outValue.Data;
            mDefaultBottomBorderColor = SetColorAlpha(themeForeGround, DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);

            mDefaultTabColorizer = new SimpleTabColorizer1();
            mDefaultTabColorizer.IndicatorColors = INDICATOR_COLORS;
            mDefaultTabColorizer.DividerColors = DIVIDER_COLORS;

            mBottomBorderThickness = (int)(DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density);
            mBottomBorderPaint = new Paint();
            mBottomBorderPaint.Color = GetColorFromInteger(0xC5C5C5); //Gray

            mSelectedIndicatorThickness = (int)(SELECTED_INDICATOR_THICKNESS_DIPS * density);
            mSelectedIndicatorPaint = new Paint();

            mDividerHeight = DEFAULT_DIVIDER_HEIGHT;
            mDividerPaint = new Paint();
            mDividerPaint.StrokeWidth = (int)(DEFAULT_DIVIDER_THICKNESS_DIPS * density);
        }
开发者ID:ThanhBui92,项目名称:OrigamiApp,代码行数:27,代码来源:SlidingTabStrip1.cs


示例3: CircleImageView

		public CircleImageView(Context context, IAttributeSet attrs, int defStyle)
			: base(context, attrs, defStyle)
		{

			// init paint
			paint = new Paint();
			paint.AntiAlias = true;

			paintBorder = new Paint();
			paintBorder.AntiAlias = true;

			// load the styled attributes and set their properties
			TypedArray attributes = context.ObtainStyledAttributes(attrs, Resource.Styleable.CircularImageView, defStyle, 0);

			if (attributes.GetBoolean(Resource.Styleable.CircularImageView_border, true))
			{
				int defaultBorderSize = (int)(4 * context.Resources.DisplayMetrics.Density+ 0.5f);
				BorderWidth = attributes.GetDimensionPixelOffset(Resource.Styleable.CircularImageView_border_width, defaultBorderSize);
				BorderColor = attributes.GetColor(Resource.Styleable.CircularImageView_border_color, Color.White);
			}

			if (attributes.GetBoolean(Resource.Styleable.CircularImageView_shadow, false))
			{
				addShadow();
			}
		}
开发者ID:scrafty614,项目名称:XamarinStudio_Example,代码行数:26,代码来源:CircleImageView.cs


示例4: Initialize

		void Initialize ()
		{
			mPaint = new Paint ();
			mPaint.Color = Color.Black;
			mPaint.AntiAlias = true;
			mPaint.SetStyle (Paint.Style.Fill);
		}
开发者ID:KiranKumarAlugonda,项目名称:TXTSHD,代码行数:7,代码来源:CircleView.cs


示例5: DrawShape

 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;
   }
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:25,代码来源:ShapeView.cs


示例6: MapPlotter

        //        Tile tile;
        public MapPlotter(int size)
        {
            this.size = size;

            defaultPaint = new Paint();
            defaultPaint.Fill = PlotterHelper.DEFAULT_COLOR;

            roadPaint = new Paint();
            roadPaint.StrokeCap = PenLineCap.Round;

            roadBorderPaint = new Paint();
            roadBorderPaint.Stroke = PlotterHelper.ROAD_BORDER_COLOR;
            roadBorderPaint.StrokeCap = PenLineCap.Round;

            grassPaint = new Paint();
            grassPaint.Fill = PlotterHelper.NATURE_GRASS_COLOR;

            waterPaint = new Paint();
            waterPaint.Fill = PlotterHelper.NATURE_WATER_COLOR;

            riverPaint = new Paint();
            riverPaint.Stroke = PlotterHelper.NATURE_RIVER_COLOR;
            riverPaint.StrokeCap = PenLineCap.Round;

            buildingPaint = new Paint();
        }
开发者ID:ackratos,项目名称:USTCMap,代码行数:27,代码来源:MapPlotter.cs


示例7: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);

            var r = new Rect ();
            this.GetLocalVisibleRect (r);

            var half = r.Width() / 2;
            var height = r.Height();

            var percentage = (this.Limit - Math.Abs(this.CurrentValue)) / this.Limit;


            var paint = new Paint()
            {
                Color = this.CurrentValue < 0 ? this.negativeColor : this.positiveColor,
                StrokeWidth = 5
            };

            paint.SetStyle(Paint.Style.Fill);

            if (this.CurrentValue < 0)
            {
                var start = (float)percentage * half;
                var size = half - start;
                canvas.DrawRect (new Rect ((int)start, 0, (int)(start + size), height), paint);
            }
            else
            {
                canvas.DrawRect (new Rect((int)half, 0, (int)(half + percentage * half), height), paint);
            }
        }
开发者ID:GGHG72,项目名称:Xamarin-Forms-Labs,代码行数:32,代码来源:SensorBarDroidView.cs


示例8: BezelImageView

	    public BezelImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
		{
			// Attribute initialization
	        var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.BezelImageView, defStyle, 0);
	
	        mMaskDrawable = a.GetDrawable(Resource.Styleable.BezelImageView_maskDrawable);
	        if (mMaskDrawable == null) {
	            mMaskDrawable = Resources.GetDrawable(Resource.Drawable.bezel_mask);
	        }
	        mMaskDrawable.Callback = this;
	
	        mBorderDrawable = a.GetDrawable(Resource.Styleable.BezelImageView_borderDrawable);
	        if (mBorderDrawable == null) {
	            mBorderDrawable = Resources.GetDrawable(Resource.Drawable.bezel_border);
	        }
	        mBorderDrawable.Callback = this;
	
	        a.Recycle();
	
	        // Other initialization
	        mMaskedPaint = new Paint();
	        mMaskedPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcAtop));
	
	        mCopyPaint = new Paint();
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:25,代码来源:BezelImageView.cs


示例9: GetRoundedCornerBitmap

		// If you would like to create a circle of the image set pixels to half the width of the image.
		internal static   Bitmap GetRoundedCornerBitmap(Bitmap bitmap, int pixels)
		{
			Bitmap output = null;

			try
			{
				output = Bitmap.CreateBitmap(bitmap.Width, bitmap.Height, Bitmap.Config.Argb8888);
				Canvas canvas = new Canvas(output);

				Color color = new Color(66, 66, 66);
				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, bitmap.Width, bitmap.Height);
				RectF rectF = new RectF(rect);
				float roundPx = pixels;

				paint.AntiAlias = true;
				canvas.DrawARGB(0, 0, 0, 0);
				paint.Color = color;
				canvas.DrawRoundRect(rectF, roundPx, roundPx, paint);

				paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
				canvas.DrawBitmap(bitmap, rect, rect, paint);
			}
			catch (System.Exception err)
			{
				System.Console.WriteLine ("GetRoundedCornerBitmap Error - " + err.Message);
			}

			return output;
		}
开发者ID:suchithm,项目名称:SampleImageBitMap,代码行数:31,代码来源:ImageHelper.cs


示例10: SampleView

			public SampleView (Context context) : base (context)
			{
				Focusable = true;

				mPaint = new Paint ();
				mPaint.AntiAlias = true;
			}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:7,代码来源:Layers.cs


示例11: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            base.Draw (canvas);

            Paint mBgPaints = new Paint ();
            mBgPaints.AntiAlias = true;
            mBgPaints.SetStyle (Paint.Style.Fill);
            mBgPaints.Color = Color.Blue;
            mBgPaints.StrokeWidth = 0.5f;

            Paint tPaint = new Paint ();
            tPaint.Alpha = 0;
            canvas.DrawColor (tPaint.Color);

            RectF mOvals = new RectF (40, 40, layout.MeasuredWidth - 40, layout.MeasuredHeight - 40);

            decimal total = 0;
            foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
                total += value.amount;
            }

            if (total == 0) {
                return;
            }

            decimal degressPerAmount = 360 / total;
            decimal currentAngle = 0;
            foreach (SecuritiesViewModel.PieChartValue value in securitiesViewModel.DataForPieChart ()) {
                canvas.DrawArc (mOvals, (float)currentAngle, (float)(degressPerAmount * value.amount), true, mBgPaints);
                currentAngle += (degressPerAmount * value.amount);
                mBgPaints.SetARGB (255, new Random ().Next (256), new Random ().Next (256), new Random ().Next (256));
            }
        }
开发者ID:sadiq81,项目名称:Pengeplan_Xamarin,代码行数:33,代码来源:PieView.cs


示例12: applyFilterElements

		public void applyFilterElements(Paint pPaint) {
			this.mSVGAttributes.getFloatAttribute(SVGConstants.ATTRIBUTE_X, true);
			List<ISVGFilterElement> svgFilterElements = this.mSVGFilterElements;
			for(int i = 0; i < svgFilterElements.Count; i++) {
				svgFilterElements[i].Apply(pPaint);
			}
		}
开发者ID:jdluzen,项目名称:xamsvg,代码行数:7,代码来源:SVGFilter.cs


示例13: test_alphagradients

		static void test_alphagradients (Canvas canvas)
		{
			canvas.translate (20, 10);

			RectF r = new RectF (10, 10, 410, 30);
			Paint p = new Paint (), p2 = new Paint ();
			p2.setStyle (Paint.Style.STROKE);

			using (Shader shader = setgrad (r, 0xFF00FF00, 0x0000FF00))
				p.setShader (shader);
			canvas.drawRect (r, p);
			canvas.drawRect (r, p2);

			r.offset (0, r.height () + 4);
			using (Shader shader = setgrad(r, 0xFF00FF00, 0x00000000))
				p.setShader (shader);
			canvas.drawRect (r, p);
			canvas.drawRect (r, p2);

			r.offset (0, r.height () + 4);
			using (Shader shader = setgrad(r, 0xFF00FF00, 0x00FF0000))
				p.setShader (shader);
			canvas.drawRect (r, p);
			canvas.drawRect (r, p2);
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:25,代码来源:Gradients.cs


示例14: ApplyCustomTypeFace

        private static void ApplyCustomTypeFace(Paint paint, Typeface tf, Android.Graphics.Color color)
        {
            int oldStyle;
            Typeface old = paint.Typeface;
            if (old == null)
            {
                oldStyle = 0;
            }
            else
            {
                oldStyle = (int)old.Style;
            }

            int fake = oldStyle & ~(int)tf.Style;
            if ((fake & (int)TypefaceStyle.Bold) != 0)
            {
                paint.FakeBoldText = true;
            }

            if ((fake & (int)TypefaceStyle.Italic) != 0)
            {
                paint.TextSkewX = -0.25f;
            }



            paint.SetARGB(color.A, color.R, color.G, color.B);

            paint.SetTypeface(tf);
        }
开发者ID:renatojunior2009,项目名称:Xamarin-Forms-Labs,代码行数:30,代码来源:CustomTypeFaceSpan.cs


示例15: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            base.Draw(canvas);

            var rect = new RectF(0,0,300,300);
            switch (TheShape)
            {
                case Shape.Circle:
                    canvas.DrawOval(rect, new Paint() { Color = Color.Aqua });
                    break;
                case Shape.Square:
                    canvas.DrawRect(rect, new Paint() { Color = Color.Red });
                    break;
                case Shape.Triangle:
                    var path = new Path();
                    path.MoveTo(rect.CenterX(), 0);
                    path.LineTo(0, rect.Height());
                    path.LineTo(rect.Width(), rect.Height());
                    path.Close();

                    var paint = new Paint() {Color = Color.Magenta};
                    paint.SetStyle(Paint.Style.Fill);
                    canvas.DrawPath(path, paint);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:KiranKumarAlugonda,项目名称:NPlus1DaysOfMvvmCross,代码行数:29,代码来源:CustomDrawShapeView.cs


示例16: OnElementSizeChanged

        void OnElementSizeChanged(object sender, EventArgs e)
        {
            var elem = sender as View;
            if (elem == null)
                return;

            var density = Resources.System.DisplayMetrics.Density;

            using (var imageBitmap = Bitmap.CreateBitmap((int)((elem.Width + 2) * density), (int)((elem.Height + 1) * density), Bitmap.Config.Argb8888))
            using (var canvas = new Canvas(imageBitmap))
            using (var paint = new Paint() { Dither = false, Color = Xamarin.Forms.Color.White.ToAndroid(), AntiAlias = true })
            {
                paint.Hinting = PaintHinting.On;
                paint.Flags = PaintFlags.AntiAlias;
                paint.SetStyle(Paint.Style.Stroke);
                paint.StrokeWidth = 2 * density;

                var height = (float)elem.Height;

                canvas.DrawRoundRect(new RectF(density, density, (float)(elem.Width) * density, (float)(height) * density), height * density / 2, height * density / 2, paint);
                canvas.Density = (int)density;

                Container.Background = new BitmapDrawable(imageBitmap);
            }
        }
开发者ID:antixaker,项目名称:ProgressBar,代码行数:25,代码来源:BorderEffect.cs


示例17: DrawingImageView

	public DrawingImageView(Context context, Fragment fragment): base(context) {
		mPaint = new Paint();
		mPaint.AntiAlias = true;
		mPaint.Dither = true;
		mPaint.Color = Color.Yellow;
		mPaint.SetStyle (Paint.Style.Stroke);
		mPaint.StrokeJoin = Paint.Join.Round;
		mPaint.StrokeCap = Paint.Cap.Round;
		mPaint.StrokeWidth = 10;

		cPaint = new Paint ();
		cPaint.Color = Color.Yellow;
		cPaint.StrokeJoin = Paint.Join.Round;
		cPaint.StrokeCap = Paint.Cap.Round;
		cPaint.SetTypeface(Typeface.Default);
		cPaint.TextSize = 40;

		mPath = new Android.Graphics.Path();
		mBitmapPaint = new Paint();
		mBitmapPaint.Color = Color.Yellow;

		DrawingStatus = DrawingType.None;

		_fragment = fragment;
	}
开发者ID:ehill8624,项目名称:ValkreRender,代码行数:25,代码来源:DrawingImageView.cs


示例18: DrawChild

 protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
 {
     try
     {
         var radius = Math.Min(Width, Height) / 2;
         var strokeWidth = 10;
         radius -= strokeWidth / 2;
         //Create path to clip
         var path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         canvas.Save();
         canvas.ClipPath(path);
         var result = base.DrawChild(canvas, child, drawingTime);
         canvas.Restore();
         // Create path for circle border
         path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         var paint = new Paint();
         paint.AntiAlias = true;
         paint.StrokeWidth = 5;
         paint.SetStyle(Paint.Style.Stroke);
         paint.Color = global::Android.Graphics.Color.White;
         canvas.DrawPath(path, paint);
         //Properly dispose
         paint.Dispose();
         path.Dispose();
         return result;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to create circle image: " + ex);
     }
     return base.DrawChild(canvas, child, drawingTime);
 }
开发者ID:colbylwilliams,项目名称:BasicBeer-Forms,代码行数:34,代码来源:CircleImage.cs


示例19: onDraw

		protected override void onDraw (Canvas canvas)
		{
			canvas.drawColor (unchecked((int)0xFFDDDDDD));

			Paint paint = new Paint ();
			paint.setAntiAlias (true);
			paint.setStyle (Paint.Style.STROKE);
			paint.setStrokeWidth (3);
			paint.setStyle (Paint.Style.FILL);

			RectF r = new RectF ();
			float t, x, y;

			t = GetAnimScalar (25, 500);

			canvas.translate (320, 240);

			for (int i = 0; i < 35; i++) {
				paint.setColor (unchecked((int)0xFFF00FF0 - i * 0x04000000));
				double step = Math.PI / (55 - i);
				double angle = t * step;
				x = (20 + i * 5) * (float)Math.Sin (angle);
				y = (20 + i * 5) * (float)Math.Cos (angle);
				r.set (x, y, x + 10, y + 10);
				canvas.drawRect (r, paint);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:27,代码来源:Spiral.cs


示例20: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);

            SetContentView(Resource.Layout.Main);

            _colorMatrix = new ColorMatrix();
            _colorMatrixFilter = new ColorMatrixColorFilter(_colorMatrix);

            _paint = new Paint();
            _paint.SetColorFilter(_colorMatrixFilter);

            var contrast = FindViewById<SeekBar>(Resource.Id.contrast);
            contrast.KeyProgressIncrement = 1;
            contrast.ProgressChanged += ContrastChanged;

            var brightness = FindViewById<SeekBar>(Resource.Id.brightness);
            brightness.KeyProgressIncrement = 1;
            brightness.ProgressChanged += BrightnessChanged;

            var saturation = FindViewById<SeekBar>(Resource.Id.saturation);
            saturation.KeyProgressIncrement = 1;
            saturation.ProgressChanged += SaturationChanged;

            var imageSelector = FindViewById<Button>(Resource.Id.selectImage);
            imageSelector.Click += ImagesSelectorClick;

            _imageViewer = FindViewById<ImageView>(Resource.Id.imageViewer);
        }
开发者ID:aca1490,项目名称:Basic-Image-Editor,代码行数:30,代码来源:MainActivity.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# PaintEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# PagingInfo类代码示例发布时间: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