private void skiaCanvas_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var surface = e.Surface; surfaceWidth = e.Info.Width; surfaceHeight = e.Info.Height; var canvas = surface.Canvas; var rect = SKRect.Create(10, 10, surfaceWidth - 20, surfaceHeight - 20); var paint = new SKPaint { Style = SKPaintStyle.Fill, Color = SKColors.AliceBlue }; canvas.ResetMatrix(); canvas.DrawRect(rect, paint); if (bitmap != null) { canvas.DrawBitmap(bitmap, 0, 0); } canvas.Flush(); }
private void GraphGrid_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { GridSurface = e.Surface; GridCanvas = GridSurface.Canvas; if (GridYEnabled) { // draw y grid lines pixelsPerUnitY = graphGrid.CanvasSize.Height / (GridYMax - GridYMin); float stepSizeY = GridYStep; for (float y = (stepSizeY * pixelsPerUnitY); y < graphGrid.CanvasSize.Height; y += (stepSizeY * pixelsPerUnitY)) { GridCanvas.DrawLine(0, y, graphGrid.CanvasSize.Width, y, GridPaint1); } } if (GridXEnabled) { // draw x grid lines pixelsPerUnitX = graphGrid.CanvasSize.Width / (GridXMax - GridXMin); float stepSizeX = GridXStep; for (float x = (stepSizeX * pixelsPerUnitX); x < graphGrid.CanvasSize.Width; x += (stepSizeX * pixelsPerUnitX)) { GridCanvas.DrawLine(x, 0, x, graphGrid.CanvasSize.Height, GridPaint1); } } GridCanvas.DrawRect(0, 0, graphGrid.CanvasSize.Width - 2, graphGrid.CanvasSize.Height - 2, GridPaint1); refresh = true; }
private void GraphMain_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { MainSurface = e.Surface; MainCanvas = MainSurface.Canvas; if (refresh) { MainCanvas.Clear(SKColors.Black); refresh = false; } // draw eraser MainCanvas.DrawRect(currentX, 0, 40, graphMain.CanvasSize.Height, ErasePaint); if (ClearFlag) { //MainCanvas.Clear(SKColors.Transparent); ClearFlag = false; if (displayArray1 != null && displayArray1.Length > 0) { MainCanvas.DrawPoints(PointMode2, displayArray1, GraphPaint1); } } else { if (displayArray1 != null && displayArray1.Length > 0) { MainCanvas.DrawPoints(PointMode1, displayArray1, GraphPaint1); } } }
private void SKElement_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { ICanvas canvas = new SkiaCanvas() { Canvas = e.Surface.Canvas }; //canvas.FillColor = Colors.Transparent; //canvas.FillColor = Colors.White.WithAlpha(0.9f); //canvas.FillRectangle(0, 0, (float)DrawSurface.ActualWidth, (float)DrawSurface.ActualHeight); //canvas.StrokeColor = Colors.Red.WithAlpha(.5f); canvas.StrokeColor = Colors.Red; canvas.StrokeSize = 2; var path = new PathF(); if (_points.Count > 0) { path.MoveTo(_points[0].X, _points[0].Y); for (int i = 1; i < _points.Count; i++) { path.LineTo(_points[i].X, _points[i].Y); } //path.Close(); canvas.DrawPath(path); } }
private void GraphGrid_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { GridSurface = e.Surface; GridCanvas = GridSurface.Canvas; GridCanvas.Clear(SKColors.White); if (GridYEnabled) { // draw y grid lines pixelsPerUnitY = graphGrid.CanvasSize.Height / (GridYMax - GridYMin); float stepSizeY = GridYStep; float gridYText = GridYMax; for (float y = 0; y <= graphGrid.CanvasSize.Height; y += (stepSizeY * pixelsPerUnitY)) { GridCanvas.DrawLine(0, y, graphGrid.CanvasSize.Width, y, GridPaint1); GridCanvas.DrawText(gridYText.ToString(), 5, y - 5, GridText1); gridYText -= stepSizeY; } } if (GridXEnabled) { // draw x grid lines float pixelsPerUnitX = graphGrid.CanvasSize.Width / (GridXMax - GridXMin); float stepSizeX = GridXStep; for (float x = 0; x <= graphGrid.CanvasSize.Width; x += (stepSizeX * pixelsPerUnitX)) { GridCanvas.DrawLine(x, 0, x, graphGrid.CanvasSize.Height, GridPaint1); } } // rpint the legend float x1 = 300; float x2 = x1 + 120; float x3 = x2 + 120; float x4 = x3 + 120; float x5 = x4 + 120; float y1 = 30; GridCanvas.DrawText(Legend1, x1, y1, GraphPaint1); GridCanvas.DrawText(Legend2, x2, y1, GraphPaint2); GridCanvas.DrawText(Legend3, x3, y1, GraphPaint3); GridCanvas.DrawText(Legend4, x4, y1, GraphPaint4); GridCanvas.DrawText(Legend5, x5, y1, GraphPaint5); if (!AutoScale) { refresh = true; } }
private void surface_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { if (!enabled) { return; } SKCanvas canvas = e.Surface.Canvas; canvas.Clear(); float width = e.Info.Width; float height = e.Info.Height; // Draw axis canvas.DrawColor(SKColors.LightGray); canvas.DrawLine(0, 0, 0, height, black); canvas.DrawLine(0, height - 1.5f, width, height - 1.5f, black); canvas.DrawText("X2", 28.0f, 35.0f, black); canvas.DrawText("X1", width - 45.0f, height - 35.0f, black); // Draw dots foreach (SKPoint pt in red_points) { canvas.DrawCircle(pt, 5, red); } foreach (SKPoint pt in blue_points) { canvas.DrawCircle(pt, 5, blue); } }
private void OnPaintSurface(object sender, SKNativePaintSurfaceEventArgs e) { var controller = Element as ISKCanvasViewController; // the control is being repainted, let the user know controller?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info)); }
private void GraphMain_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { MainSurface = e.Surface; MainCanvas = MainSurface.Canvas; if (refresh) { MainCanvas.Clear(SKColors.Transparent); refresh = false; } // draw eraser parameter1Array = parameter1List.ToArray(); MainCanvas.DrawPoints(PointMode1, parameter1Array, GraphPaint1); parameter2Array = parameter2List.ToArray(); MainCanvas.DrawPoints(PointMode1, parameter2Array, GraphPaint2); parameter3Array = parameter3List.ToArray(); MainCanvas.DrawPoints(PointMode1, parameter3Array, GraphPaint3); parameter4Array = parameter4List.ToArray(); MainCanvas.DrawPoints(PointMode1, parameter4Array, GraphPaint4); parameter5Array = parameter5List.ToArray(); MainCanvas.DrawPoints(PointMode1, parameter5Array, GraphPaint5); //MainCanvas.DrawRect(currentX + xStepSize, 0, 40, graphMain.CanvasSize.Height, ErasePaint); firstValueCounter++; }
private void ShowcaseView_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; canvas.Clear(SKColors.White); var showcaseView = sender as SkiaSharp.Views.WPF.SKElement; var map = Showcase.Maps[int.Parse(showcaseView.Tag.ToString())]; for (int x = 0; x < map.Size; ++x) { for (int y = 0; y < map.Size; ++y) { var skRect = new SKRect( (x * (float)TileSize.Width + TileMargin) * (float)DpiScaler.Scale.Value, (y * (float)TileSize.Height + TileMargin) * (float)DpiScaler.Scale.Value, ((x + 1) * (float)TileSize.Width) * (float)DpiScaler.Scale.Value, ((y + 1) * (float)TileSize.Height) * (float)DpiScaler.Scale.Value); var tile = map.GetTile(x, y); if (tile is not null) { Paint.Color = new(tile.Color); canvas.DrawRect(skRect, Paint); } } } }
private void GraphMain_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { MainSurface = e.Surface; MainCanvas = MainSurface.Canvas; if (clearRefreshCounter > ClearRefreshRate) { clearRefreshCounter = 0; refresh = true; } clearRefreshCounter++; if (refresh) { MainCanvas.Clear(SKColors.Transparent); refresh = false; } if (displayArray1 != null && displayArray1.Length > 0) { MainCanvas.DrawPoints(PointMode1, displayArray1, GraphPaint1); } }
private void skiaCanvasElement_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; var info = e.Info; var size = e.Info.Size; canvas.Clear(SKColors.Transparent); // Draw text var textPaint = new SKPaint { IsAntialias = true, TextSize = 50, TextAlign = SKTextAlign.Center, Color = 0xFF3498DB, Style = SKPaintStyle.Fill, Typeface = SKTypeface.FromFamilyName("Trebuchet") }; canvas.DrawText( "SkiaSharp", size.Width / 2, (size.Height + textPaint.TextSize) / 2, textPaint); // Draw circle SKPaint circlePaint = new SKPaint { Style = SKPaintStyle.Stroke, Color = new SKColor(0, 150, 0), StrokeWidth = 5 }; canvas.DrawCircle(e.Info.Width / 2, e.Info.Height / 2, 100, circlePaint); /* * // Create the path * SKPath path = new SKPath(); * // Define the first contour * path.MoveTo(0.5f * info.Width, 0.1f * info.Height); * path.LineTo(0.2f * info.Width, 0.4f * info.Height); * path.LineTo(0.8f * info.Width, 0.4f * info.Height); * path.LineTo(0.5f * info.Width, 0.1f * info.Height); * // Create two SKPaint objects * SKPaint strokePaint = new SKPaint * { * Style = SKPaintStyle.Stroke, * Color = SKColors.Magenta, * StrokeWidth = 50 * }; * // Fill and stroke the path * canvas.DrawPath(path, strokePaint); */ if (path != null) { canvas.DrawPath(path, pathStrokePaint); } }
private void ThisElement_PaintSurface(object?sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { if (_hasLoaded == false) { return; } Element.StartInvalidate(e.Surface.Canvas, e.Info.Width, e.Info.Height); }
//private void LilyPadWPF_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) //{ // if (Command == null || ThisLily == null) // { // return; // } // Command.Execute(ThisLily); //} private void PaintSurface(object?sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { if (_thisDraw == null) { return; } _lily.DrawImage(e.Surface.Canvas, e.Info.Width, e.Info.Height); }
private void OnTimerSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var surface = e.Surface; var info = e.Info; var canvas = surface.Canvas; DrawTimer(canvas, info); }
void OnPlatformPaint(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { Drawer.CurrentCanvas = e.Surface.Canvas; Drawer.CurrentCanvasSize = e.Info.Size; Drawer.CurrentCanvas.Clear(SKColors.Black); Game.OnDraw(Frame, Drawer); }
private void Canvas_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { if (exampleBase != null) { painter.Canvas = e.Surface.Canvas; exampleBase.Draw(painter); } }
private void skControl1_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; GameRenderer gameRenderer = new GameRenderer(canvas, _scale, 80, GetHexagonHeight(80), new SKSize(skControl1.Width, skControl1.Height)); gameRenderer.ShowScoreboard = true; gameRenderer.ShowRobotId = chkShowRobotId.Checked; if (_timer.Enabled) { gameRenderer.Speed = timerSpeed; } else { gameRenderer.Speed = 0; } if (cboIndicator.SelectedItem == null || ((RobotIdSelection)cboIndicator.SelectedItem).IsNone) { gameRenderer.ShowDebugIndicators = false; } else if (((RobotIdSelection)cboIndicator.SelectedItem).IsAll) { gameRenderer.ShowDebugIndicators = true; gameRenderer.ShowAllDebugIndicators = true; } else { gameRenderer.ShowDebugIndicators = true; gameRenderer.ShowAllDebugIndicators = false; gameRenderer.ShowDebugIndicatorRobotId = ((RobotIdSelection)cboIndicator.SelectedItem).Id; } if (_gameController != null) { if (_gameController.Round == 0) { gameRenderer.DrawStartScreen(_gameController.BlueTeamName, _gameController.RedTeamName); } else if (_gameController.IsFinished) { gameRenderer.DrawWinnerScreen(_gameController.WinnerTeam, _gameController.WinnerTeam == Team.Blue ? _gameController.BlueTeamName : _gameController.RedTeamName); } else { lock (_syncLockObj) { gameRenderer.DrawGame(_gameController); } } } else { gameRenderer.DrawInfo(); } }
// Fill in strain data points between hit objects // Return: times in first list, values in second list private void skControl_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var surface = e.Surface; var width = e.Info.Width; var height = e.Info.Height; var canvas = surface.Canvas; canvas.Clear(SKColors.Black); RenderGame(canvas, width, height); canvas.Flush(); }
private void MainView_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; canvas.Clear(SKColors.White); for (int x = 0; x < GameMap.Size; ++x) { for (int y = 0; y < GameMap.Size; ++y) { var skRect = new SKRect( (x * (float)TileSize.Width + TileMargin) * (float)DpiScaler.Scale.Value, (y * (float)TileSize.Height + TileMargin) * (float)DpiScaler.Scale.Value, ((x + 1) * (float)TileSize.Width) * (float)DpiScaler.Scale.Value, ((y + 1) * (float)TileSize.Height) * (float)DpiScaler.Scale.Value); var tile = GameMap.GetTile(x, y); if (tile is null) { Paint.Color = new(0xffd6d6d6); } else { Paint.Color = new(tile.Color); } canvas.DrawRect(skRect, Paint); } } // debug if (Captured is not null && !Lost) { Paint.Color = new(0x44ffffff); var draggableLoc = GetHoveredLocation(GameMap, DpiScaler.ScaleDown(Captured.Point), false); if (draggableLoc is not null) { foreach (var tile in Captured.Figure.GetTiles()) { var safeDraggableLoc = draggableLoc.Value; var skRect = new SKRect( ((safeDraggableLoc.X + tile.X) * (float)TileSize.Width + TileMargin) * (float)DpiScaler.Scale.Value, ((safeDraggableLoc.Y + tile.Y) * (float)TileSize.Height + TileMargin) * (float)DpiScaler.Scale.Value, ((safeDraggableLoc.X + tile.X + 1) * (float)TileSize.Width) * (float)DpiScaler.Scale.Value, ((safeDraggableLoc.Y + tile.Y + 1) * (float)TileSize.Height) * (float)DpiScaler.Scale.Value); canvas.DrawRect(skRect, Paint); } } } }
private void skControl1_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var surface = e.Surface; var surfaceWidth = e.Info.Width; var surfaceHeight = e.Info.Height; var canvas = surface.Canvas; canvas.Clear(); // draw on the canvas var minute = (float)DateTime.Now.Minute; var hour = (float)DateTime.Now.Hour; var sec = (float)DateTime.Now.Second; StyleKitName.drawClock(canvas, null, new SKRect(0, 0, surfaceWidth, surfaceHeight), PaintCode.ResizingBehavior.AspectFit, new SKColor(40, 40, 40), new SKColor(10, 10, 10), new SKColor(40, 190, 30), new SKColor(128, 128, 128), new SKColor(128, 128, 222), new SKColor(228, 228, 228), hour, minute, sec); }
private void Canvas_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var skCanvas = e.Surface.Canvas; skCanvas.Clear(new SkiaSharp.SKColor(255, 255, 255)); using (var paint = new SKPaint()) { paint.TextSize = 36.0f; paint.IsAntialias = true; paint.Color = (SKColor)0xFF4281A4; paint.IsStroke = false; skCanvas.DrawText("PixelFarm+SkiaSharp MemoryCanvas", 20, 64.0f, paint); paint.StrokeWidth = 3; skCanvas.DrawLine(0, 0, 100, 80, paint); } }
private void SKElement_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { ICanvas canvas = new SkiaCanvas() { Canvas = e.Surface.Canvas }; canvas.StrokeColor = Colors.Red; canvas.StrokeSize = 2; //draw many points var path = new PathF(); if (_points.Count > 0) { path.MoveTo(_points[0].X, _points[0].Y); for (int i = 1; i < _points.Count; i++) { path.LineTo(_points[i].X, _points[i].Y); } canvas.DrawPath(path); } }
private void skControl1_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { if (Map != null) { var canvas = e.Surface.Canvas; _gameRenderer = new GameRenderer(canvas, _scale, 80, Form1.GetHexagonHeight(80), new SKSize(skControl1.Width, skControl1.Height)); _gameRenderer.DrawMap(Map, new List <Common.Location>()); foreach (Location loc in _currentLocations) { _gameRenderer.DrawDebugIndicatorCircle(new Engine.Debug.DebugIndicatorCircle() { Color = DebugColor.Red, Location = loc, RobotController = null }); } //canvas.DrawCircle(, 10f, _gameRenderer.Paints.TerrainStroke); } }
private void DraggingView_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; if (!Lost) { canvas.Clear(SKColors.Transparent); var tiles = Captured.Figure.GetTiles(); if (tiles is null) { return; } foreach (var tile in tiles) { Paint.Color = new(tile.Color); int x = tile.X; int y = tile.Y; var skRect = new SKRect( ((float)Captured.Point.X / (float)DpiScaler.Scale.Value + x * (float)TileSize.Width + TileMargin) * (float)DpiScaler.Scale.Value, ((float)Captured.Point.Y / (float)DpiScaler.Scale.Value + y * (float)TileSize.Height + TileMargin) * (float)DpiScaler.Scale.Value, ((float)Captured.Point.X / (float)DpiScaler.Scale.Value + (x + 1) * (float)TileSize.Width) * (float)DpiScaler.Scale.Value, ((float)Captured.Point.Y / (float)DpiScaler.Scale.Value + (y + 1) * (float)TileSize.Height) * (float)DpiScaler.Scale.Value); canvas.DrawRect(skRect, Paint); } } else { canvas.Clear(new SKColor(0x88ffffff)); Paint.Color = SKColors.Black; using SKPaint paint = new SKPaint { Color = SKColors.Black, TextSize = 30, IsStroke = false, TextAlign = SKTextAlign.Center }; canvas.DrawText($"Вы проиграли! Счёт: {Engine.Engine.Score}/{Properties.Settings.Default.BestScore}", (float)DraggingView.ActualWidth / 2, (float)DraggingView.ActualHeight / 2, paint); } }
private void GraphGrid_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { GridSurface = e.Surface; GridCanvas = GridSurface.Canvas; GridCanvas.Clear(SKColors.Black); if (GridYEnabled) { // draw y grid lines pixelsPerUnitY = graphGrid.CanvasSize.Height / (GridYMax - GridYMin); float stepSizeY = GridYStep; for (float y = 0; y <= graphGrid.CanvasSize.Height; y += (stepSizeY * pixelsPerUnitY)) { GridCanvas.DrawLine(0, y, graphGrid.CanvasSize.Width, y, GridPaint1); } } if (GridXEnabled) { // draw x grid lines float pixelsPerUnitX = graphGrid.CanvasSize.Width / (GridXMax - GridXMin); float stepSizeX = GridXStep; for (float x = 0; x <= graphGrid.CanvasSize.Width; x += (stepSizeX * pixelsPerUnitX)) { GridCanvas.DrawLine(x, 0, x, graphGrid.CanvasSize.Height, GridPaint1); } } if (!AutoScale) { refresh = true; } }
private void canvasView_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; canvas.Clear(); lines.ForEach((line) => { canvas.DrawLine( ToScreenSpace(line.start), ToScreenSpace(line.end), SkiaKit.blackPaint); } ); // X canvas.DrawLine( ToScreenSpace(new Point3D(2, 0, 0)), ToScreenSpace(new Point3D(-2, 0, 0)), SkiaKit.redPaint ); // Y canvas.DrawLine( ToScreenSpace(new Point3D(0, 2, 0)), ToScreenSpace(new Point3D(0, -2, 0)), SkiaKit.greenPaint ); // Z canvas.DrawLine( ToScreenSpace(new Point3D(0, 0, 2)), ToScreenSpace(new Point3D(0, 0, -2)), SkiaKit.greenPaint );; }
void OnPaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { // the control is being repainted, let the user know (Element as ISKCanvasViewController)?.OnPaintSurface(new SKPaintSurfaceEventArgs(e.Surface, e.Info)); }
void OnPlatformPaint(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { PaintArgs.Surface = e.Surface; OnPaint?.Invoke(this, PaintArgs); }
private void SKElement_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { _client.OnPaintSurface(e.Info, e.Surface); }
private void ThisDraw_PaintSurface(object?sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { _game.DrawBoard(e.Surface.Canvas, e.Info.Width, e.Info.Height); }