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


C# SkiaSharp.SKPaint类代码示例

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


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

示例1: RenderRaster

        public static void RenderRaster(SKCanvas canvas, SKBitmap bitmap, SKRect rect, float opacity = 1f)
        {
            // Better for quality. Helps to compare to WPF
            var color = new SKColor(255, 255, 255, (byte)(255 * opacity));
            var paint = new SKPaint { Color = color, FilterQuality = SKFilterQuality.High };
            canvas.DrawBitmap(bitmap, rect, paint);

            // Better for performance:
            canvas.DrawBitmap(bitmap, rect);
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:10,代码来源:BitmapHelper.cs

示例2: Draw

        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry)
        {
            var lineString = ((LineString) geometry).Vertices;

            float lineWidth = 1;
            var lineColor = new Color();

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float) vectorStyle.Line.Width;
                lineColor = vectorStyle.Line.Color;
            }

            var line = WorldToScreen(viewport, lineString);
            var path = ToSkia(line);

            using (var paint = new SKPaint())
            {
                paint.IsStroke = true;
                paint.StrokeWidth = lineWidth;
                paint.Color = lineColor.ToSkia();
                paint.StrokeJoin = SKStrokeJoin.Round;

                canvas.DrawPath(path, paint);
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:28,代码来源:LineStringRenderer.cs

示例3: FormattedTextImpl

        public FormattedTextImpl(string text, string fontFamilyName, double fontSize, FontStyle fontStyle,
                    TextAlignment textAlignment, FontWeight fontWeight, TextWrapping wrapping)
        {
            _text = text ?? string.Empty;

            // Replace 0 characters with zero-width spaces (200B)
            _text = _text.Replace((char)0, (char)0x200B);

            var typeface = TypefaceCache.GetTypeface(fontFamilyName, fontStyle, fontWeight);

            _paint = new SKPaint();

            //currently Skia does not measure properly with Utf8 !!!
            //Paint.TextEncoding = SKTextEncoding.Utf8;
            _paint.TextEncoding = SKTextEncoding.Utf16;
            _paint.IsStroke = false;
            _paint.IsAntialias = true;            
            _paint.LcdRenderText = true;            
            _paint.SubpixelText = true;
            _paint.Typeface = typeface;
            _paint.TextSize = (float)fontSize;
            _paint.TextAlign = textAlignment.ToSKTextAlign();

            _wrapping = wrapping;

            Rebuild();
        }
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:27,代码来源:FormattedTextImpl.cs

示例4: Draw

        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IGeometry geometry)
        {
            var polygon = (Polygon)geometry;

            float lineWidth = 1;
            var lineColor = Color.Black; // default
            var fillColor = Color.Gray; // default

            var vectorStyle = style as VectorStyle;

            if (vectorStyle != null)
            {
                lineWidth = (float) vectorStyle.Outline.Width;
                lineColor = vectorStyle.Outline.Color;
                fillColor = vectorStyle.Fill?.Color;
            }

            using (var path = ToSkia(viewport, polygon))
            {
                using (var paint = new SKPaint())
                {
                    paint.IsAntialias = true;
                    paint.StrokeWidth = lineWidth;

                    paint.Style = SKPaintStyle.Fill;
                    paint.Color = fillColor.ToSkia();
                    canvas.DrawPath(path, paint);
                    paint.Style = SKPaintStyle.Stroke;
                    paint.Color = lineColor.ToSkia();
                    canvas.DrawPath(path, paint);
                }
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:33,代码来源:PolygonRenderer.cs

示例5: SkiaCanvasPainter

        //-----------------------
        public SkiaCanvasPainter(int w, int h)
        {

            _fill = new SKPaint();
            _stroke = new SKPaint();
            _stroke.IsStroke = true;
            _width = w;
            _height = h;
        }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:10,代码来源:SkiaCanvasPainter.cs

示例6: DrawImage

 public void DrawImage(IBitmap source, double opacity, Rect sourceRect, Rect destRect)
 {
     var impl = (BitmapImpl)source.PlatformImpl;
     var s = sourceRect.ToSKRect();
     var d = destRect.ToSKRect();
     using (var paint = new SKPaint()
             { Color = new SKColor(255, 255, 255, (byte)(255 * opacity)) })
     {
         Canvas.DrawBitmap(impl.Bitmap, s, d, paint);
     }
 }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:11,代码来源:DrawingContextImpl.cs

示例7: CreateBackgroundImage

		public SKImage CreateBackgroundImage ()
		{
			SKPaint paint = null;
			SKPath path = null;

			try 
			{
				var height = (int)Bounds.Height;
				var width = (int)Bounds.Width;

				using (var surface = SKSurface.Create (width, height, SKColorType.N_32, SKAlphaType.Premul)) 
				{
					var canvas = surface.Canvas;

					//canvas.Clear (SKColors.Beige);

					paint = new SKPaint
					{
						Color = SKColors.DarkBlue,
						IsStroke = true,
						StrokeWidth = 1,
						StrokeCap = SKStrokeCap.Round,
						IsAntialias = true
					};

					//path = new SKPath ();
					//path.MoveTo (0f, 0f);
					//path.LineTo (width, height);
					//path.Close ();

					//canvas.DrawPath (path, paint);


					//DrawArc (canvas, paint, 0, 90);

					var start = -90;
					var end = 0;

					//DrawCircle (canvas, paint, width / 2, height / 2, width / 2 - 4);
					DrawArcFromTo (canvas, paint, width / 2, height / 2, width / 2 - 4, start, end);
					DrawArcFromTo (canvas, paint, width / 2, height / 2, (int)((width / 2 - 4) * 0.8), start, end);

					return surface.Snapshot ();
				}
			} 
			finally 
			{
				if (paint != null)
					paint.Dispose ();

				if (path != null)
					path.Dispose ();
			}
		}
开发者ID:yonglehou,项目名称:Orleans.MobileDashboard,代码行数:54,代码来源:HealthIndicatorView.xaml.cs

示例8: CreateLabelAsBitmap

        private static SKBitmap CreateLabelAsBitmap(LabelStyle style, string text, SKPaint paint)
        {
            var rect = new SKRect();
            paint.MeasureText(text, ref rect);

            var backRect = new SKRect(0, 0, rect.Width + 6, rect.Height + 6);

            var bitmap = new SKBitmap((int)backRect.Width, (int)backRect.Height);

            using (var target = new SKCanvas(bitmap))
            {
                target.Clear();

                DrawBackground(style, backRect, target);
                target.DrawText(text, -rect.Left + 3, -rect.Top +3, paint);
                return bitmap;
            }
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:18,代码来源:LabelRenderer.cs

示例9: Draw

        protected override void Draw(SKCanvas canvas, int width, int height)
        {
            float time = _frame / (LengthSec * Fps);

            using (var paint = new SKPaint())
            {
                paint.Color = Foreground.ToSkia();
                paint.StrokeWidth = (float)StrokeWidth;
                paint.IsAntialias = true;
                paint.IsStroke = true;

                for (int a = 0; a < 3; ++a)
                {
                    var matrix = SKMatrix.MakeRotation(2 * (float)Math.PI * time / 6 + 2 * (float)Math.PI * a / 3);
                    matrix.TransX = width / 2f;
                    matrix.TransY = height / 2f;

                    canvas.SetMatrix(matrix);

                    const int n = 12;
                    const int sp = 39;

                    for (int i = -n; i <= n; ++i)
                    {
                        float y = (float)(i * sp * Math.Pow(2, time));
                        float tt = (float)Math.Min(1, Math.Max(0, 1.09 * time - 0.00275 * Math.Abs(y) + 0.075));

                        float x;

                        if (i % 2 == 0)
                            x = width;
                        else
                            x = width * tt;

                        if (x > 0)
                            canvas.DrawLine(-x, y, x, y, paint);
                    }
                }
            }

            ++_frame;
            if (_frame > LengthSec * Fps)
                _frame = 0;
        }
开发者ID:CriDos,项目名称:skiasharpwpfextensions,代码行数:44,代码来源:GridZoomControl.cs

示例10: CreateGraphicsFromNativeHdc

        void CreateGraphicsFromNativeHdc(int width, int height)
        {

            skBitmap = new SKBitmap(width, height);
            skCanvas = new SKCanvas(skBitmap);
            //
            stroke = new SKPaint();
            stroke.IsStroke = true;
            //
            fill = new SKPaint();
            fill.IsStroke = false;
            //
            textFill = new SKPaint();
            textFill.IsAntialias = true;
            //---------------------------------------            
             
            //---------------------------------------
            this.CurrentFont = new RequestFont("tahoma", 14);
            this.CurrentTextColor = Color.Black;
            //---------------------------------------
        }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:21,代码来源:1_MySkiaCanvas_Specific.cs

示例11: DrawPoints

 public void DrawPoints(SKPointMode mode, SKPoint [] points, SKPaint paint)
 {
     if (paint == null)
         throw new ArgumentNullException (nameof (paint));
     if (points == null)
         throw new ArgumentNullException (nameof (points));
     SkiaApi.sk_canvas_draw_points (Handle, mode, (IntPtr)points.Length, points, paint.Handle);
 }
开发者ID:Core2D,项目名称:SkiaSharp,代码行数:8,代码来源:SKCanvas.cs

示例12: ApplyTo

            public IDisposable ApplyTo(SKPaint paint)
            {
                var state = new PaintState(paint, paint.Color, paint.Shader);

                paint.Color = Paint.Color;
                paint.Shader = Paint.Shader;

                return state;
            }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:9,代码来源:DrawingContextImpl.cs

示例13: PaintWrapper

 public PaintWrapper(SKPaint paint)
 {
     Paint = paint;
     _disposable1 = null;
 }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:5,代码来源:DrawingContextImpl.cs

示例14: DrawText

        public void DrawText(string text, SKPath path, float hOffset, float vOffset, SKPaint paint)
        {
            if (text == null)
                throw new ArgumentNullException ("text");
            if (paint == null)
                throw new ArgumentNullException (nameof (paint));
            if (paint == null)
                throw new ArgumentNullException (nameof (paint));

            var bytes = Util.GetEncodedText (text, paint.TextEncoding);
            SkiaApi.sk_canvas_draw_text_on_path (Handle, bytes, bytes.Length, path.Handle, hOffset, vOffset, paint.Handle);
        }
开发者ID:Core2D,项目名称:SkiaSharp,代码行数:12,代码来源:SKCanvas.cs

示例15: DrawLine

 public void DrawLine(float x0, float y0, float x1, float y1, SKPaint paint)
 {
     if (paint == null)
         throw new ArgumentNullException (nameof (paint));
     SkiaApi.sk_canvas_draw_line (Handle, x0, y0, x1, y1, paint.Handle);
 }
开发者ID:Core2D,项目名称:SkiaSharp,代码行数:6,代码来源:SKCanvas.cs


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