public override void DrawPath(RBrush brush, RGraphicsPath path) { var b = brush.ToBrushA(); var p = path.ToPathA(); if (b.isImage) { //Console.WriteLine("Graphics.DrawPath(B.Image)"); var rect = p.rect; var texture = b.RenderTexture(IntPtr.Zero, rect); var rects = p.GetSDLRects(); foreach (SDL.SDL_Rect r in rects) { var dst_rect = r; SDL.SDL_Rect src_rect = dst_rect; src_rect.x -= rect.x; src_rect.y -= rect.y; if (SDL.SDL_RenderCopy(_renderer, texture, ref src_rect, ref dst_rect) < 0) { Helpers.ShowSDLError("Graphics.DrawPath(B):Unable to SDL_RenderCopy!"); } } SDL.SDL_DestroyTexture(texture); } else { //Console.WriteLine("Graphics.DrawPath(B.Color)"); b.color.SetToSDLRenderer(); var rects = p.GetSDLRects(); SDL.SDL_RenderFillRects(_renderer, rects.ToArray(), rects.Count); } }
public override void DrawPolygon(RBrush brush, RPoint[] points) { if (points != null && points.Length > 0) { this._g.DrawPolygon((XBrush)((BrushAdapter)brush).Brush, Utils.Convert(points), XFillMode.Winding); } }
public void DrawString(string text, RFont font, RBrush brush, int x, int y, StringFormat format, bool useStack = true) { if (useStack) { Bus.Publish(new DrawTextCommand(text, font, (RBrush)brush.Clone(), x, y, format)); } else { var b = ((BrushAdapter)brush).Brush; // var color = default(SKColor); // if (b is SolidBrush) // { // var solid = b as SolidBrush; // color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A); // } var f = ((FontAdapter)font).Font; var paint = PaintFromFont(f); paint.Color = b.Color; _c.DrawText(text, x, y, paint); if (GloablRenderSettings.IsDebug) { var textSize = GetTextBound(text, paint); _c.DrawRect(x, y - textSize.Height, textSize.Width, textSize.Height, new SKPaint { Style = SKPaintStyle.Stroke, Color = SKColors.Coral }); } } }
public void FillRectangle(RBrush brush, float x, float y, float w, float h, bool useStack = true) { if (useStack) { Bus.Publish(new FillRectCommand((RBrush)brush.Clone(), x, y, w, h)); } else { var b = ((BrushAdapter)brush).Brush; // var color = default(SKColor); // var skPaint = new SKPaint // { // Style = SKPaintStyle.Fill, // }; // if (b is SolidBrush) // { // var solid = b as SolidBrush; // skPaint.Color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A); // } else if (b is LinearGradientBrush) // { // var gradient = b as LinearGradientBrush; // var colors = gradient.LinearColors.Select(c => new SKColor(c.R, c.G, c.B, c.A)).ToArray(); // var skRectStart = new SKPoint(gradient.Rectangle.Left, gradient.Rectangle.Top); // var skRectEnd = new SKPoint(gradient.Rectangle.Right, gradient.Rectangle.Bottom); // skPaint.Shader = SKShader.CreateLinearGradient(skRectStart, skRectEnd, colors, // new[] {0.0f, 1.0f}, SKShaderTileMode.Repeat); // } // TODO: Тут не только Solid _c.DrawRect(x, y, w, h, b); } }
public override void DrawPolygon(RBrush brush, RPoint[] points) { if (points != null && points.Length > 0) { _g.FillPolygon(((BrushAdapter)brush).Brush, Utils.Convert(points)); } }
public FillRectCommand(RBrush brush, float x, float y, float w, float h) { Brush = brush; X = x; Y = y; Width = w; Height = h; }
public DrawTextCommand(string text, RFont font, RBrush brush, int x, int y, StringFormat format) { Text = text; Font = font; Brush = brush; X = x; Y = y; Format = format; }
public override void DrawPolygon(RBrush brush, RPoint[] points) { //Console.WriteLine("Graphics.DrawPolygon"); //TODO Use brush brush.ToBrushA().color.SetToSDLRenderer(); SDL.SDL_Point[] sdl_points = new SDL.SDL_Point[points.Length]; for (int i = 0; i < sdl_points.Length; i++) { sdl_points[i] = points[i].ToSDL(); } if (SDL.SDL_RenderDrawLines(_renderer, sdl_points, sdl_points.Length) < 0) { Helpers.ShowSDLError("Graphics.DrawPolygon:Unable to SDL_RenderDrawLines!"); } }
public override void DrawPolygon(RBrush brush, RPoint[] points) { if (points != null && points.Length > 0) { var g = new StreamGeometry(); using (var context = g.Open()) { context.BeginFigure(Util.Convert(points[0]), true); for (int i = 1; i < points.Length; i++) { context.LineTo(Util.Convert(points[i])); } context.EndFigure(false); } _g.DrawGeometry(((BrushAdapter)brush).Brush, null, g); } }
public override void DrawRectangle(RBrush brush, double x, double y, double width, double height) { var xBrush = ((BrushAdapter)brush).Brush; var xTextureBrush = xBrush as XTextureBrush; if (xTextureBrush != null) { xTextureBrush.DrawRectangle(this._g, x, y, width, height); } else { this._g.DrawRectangle((XBrush)xBrush, x, y, width, height); // handle bug in PdfSharp that keeps the brush color for next string draw if (xBrush is XLinearGradientBrush) { this._g.DrawRectangle(XBrushes.White, 0, 0, 0.1, 0.1); } } }
public override void DrawRectangle(RBrush brush, double x, double y, double width, double height) { //Console.WriteLine("Graphics.DrawRectangle x:{0} y:{1} w:{2} h:{3}", x, y, width, height); var brushA = brush.ToBrushA(); var rect = new SDL.SDL_Rect { x = (int)x, y = (int)y, w = (int)width, h = (int)height }; if (brushA.isImage) { //Fill with texture //Console.WriteLine("DrawRectangle(B) Image"); brushA.RenderTexture(_renderer, rect); } else { //Console.WriteLine("DrawRectangle(B) Color"); //Fill with solid color brushA.color.SetToSDLRenderer(); if (SDL.SDL_RenderFillRect(_renderer, ref rect) < 0) { Helpers.ShowSDLError("Graphics.DrawRectangle:Unable to SDL_RenderFillRect!"); } } }
public void FillPath(RBrush brush, SKPath path, bool useStack = true) { if (useStack) { Bus.Publish(new FillPathCommand((RBrush)brush.Clone(), new SKPath(path))); } else { var b = ((BrushAdapter)brush).Brush; b.IsAntialias = true; // var skPath = new SKPath(); // skPath.AddPoly(path.PathPoints.Select(p => new SKPoint(p.X, p.Y)).ToArray(), true); // var color = default(SKColor); // // if (b is SolidBrush) // { // var solid = b as SolidBrush; // color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A); // } _c.DrawPath(path, b); } }
public void FillPolygon(RBrush brush, SKPoint[] points, bool useStack) { if (useStack) { Bus.Publish(new FillPolygonCommand((RBrush)brush.Clone(), points)); } else { var b = ((BrushAdapter)brush).Brush; b.IsAntialias = true; var skPath = new SKPath(); skPath.AddPoly(points, true); // var color = default(SKColor); // // if (b is SolidBrush) // { // var solid = b as SolidBrush; // color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A); // } _c.DrawPath(skPath, b); } }
public override void DrawPath(RBrush brush, RGraphicsPath path) { _g.DrawGeometry(((BrushAdapter)brush).Brush, null, ((GraphicsPathAdapter)path).GetClosedGeometry()); }
public override void DrawRectangle(RBrush brush, double x, double y, double width, double height) { _g.FillRectangle(((BrushAdapter)brush).Brush, new Rect(x, y, width, height)); }
public override void DrawPath(RBrush brush, RGraphicsPath path) { _g.FillPath(brush, ((GraphicsPathAdapter)path).GraphicsPath); }
public override void DrawPath(RBrush brush, RGraphicsPath path) { ReleaseHdc(); _g.FillPath(((BrushAdapter)brush).Brush, ((GraphicsPathAdapter)path).GraphicsPath); }
internal static Adapters.BrushAdapter ToBrushA(this RBrush brush) { return(brush as Adapters.BrushAdapter); }
public override void DrawPath(RBrush brush, RGraphicsPath path) { this._g.DrawPath((XBrush)((BrushAdapter)brush).Brush, ((GraphicsPathAdapter)path).GraphicsPath); }
public FillPathCommand(RBrush brush, SKPath path) { Brush = brush; Path = path; }
public override void DrawRectangle(RBrush brush, double x, double y, double width, double height) { ReleaseHdc(); _g.FillRectangle(((BrushAdapter)brush).Brush, (float)x, (float)y, (float)width, (float)height); }
public override void DrawRectangle(RBrush brush, double x, double y, double width, double height) { _g.FillRectangle(brush, (float)x, (float)y, (float)width, (float)height); }
/// <summary> /// Draw simple border. /// </summary> /// <param name="border">Desired border</param> /// <param name="g">the device to draw to</param> /// <param name="box">Box which the border corresponds</param> /// <param name="brush">the brush to use</param> /// <param name="rectangle">the bounding rectangle to draw in</param> /// <returns>Beveled border path, null if there is no rounded corners</returns> public static void DrawBorder(Border border, RGraphics g, CssBox box, RBrush brush, RRect rectangle) { SetInOutsetRectanglePoints(border, box, rectangle, true, true); g.DrawPolygon(brush, _borderPts); }
public FillPolygonCommand(RBrush brush, SKPoint[] points) { Brush = brush; Points = points; }