private void _skiaView_PaintSurface(object sender, SKPaintSurfaceEventArgs e) { Stopwatch renderStopWatch = null; if (RenderOptions.ShowFrameRate) { renderStopWatch = Stopwatch.StartNew(); } //e.Surface.Canvas.Clear(new SKColor(Container.BackgroundColor.R, Container.BackgroundColor.G, Container.BackgroundColor.B, Container.BackgroundColor.A)); e.Surface.Canvas.Clear(SKColors.White); using (new SKAutoCanvasRestore(e.Surface.Canvas)) { var deviceSize = new Primitives.Size(e.Info.Width, e.Info.Height); var deviceIndSize = new Primitives.Size(_skiaView.Width, _skiaView.Height); var scaleDpi = new Primitives.Point(e.Info.Width / _skiaView.Width, e.Info.Height / _skiaView.Height); e.Surface.Canvas.Scale((float)scaleDpi.X, (float)scaleDpi.Y); _root.Measure(deviceIndSize); _root.Arrange(new Primitives.Rect(0, 0, deviceIndSize.Width, deviceIndSize.Height)); _root.Render(e.Surface.Canvas); } if (renderStopWatch != null) { renderStopWatch.Stop(); using (var ptRect = new SkiaSharp.SKPaint() .ApplyBrush(new SolidColorBrush(new Primitives.Color(0, 0, 0)))) using (var ptText = new SkiaSharp.SKPaint() .ApplyBrush(new SolidColorBrush(new Primitives.Color(255, 255, 255)))) { e.Surface.Canvas.DrawRect(e.Info.Width - 50.0f, 0.0f, 100.0f, 10.0f, ptRect); var elapsedString = renderStopWatch.ElapsedMilliseconds == 0 ? "-" : $"{(1.0 / renderStopWatch.ElapsedMilliseconds * 1000).ToString("##.00", CultureInfo.InvariantCulture)}FPS"; e.Surface.Canvas.DrawText(elapsedString, new SKPoint(e.Info.Width - 50.0f, 10.0f), ptText); } renderStopWatch.Reset(); } }
public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner) { renderingQueue.Enqueue(() => base.DrawCharacterInBounds(character, fontStyle, location, size, color, owner)); if (renderingQueue.Count > BufferSize) { FlushBuffer(); } }
public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { location = location.Translate(CurrentScore.DefaultPageSettings); } var font = TypedSettings.GetFont(fontStyle); var path = new GraphicsPath(); path.AddString(character.ToString(), font.FontFamily, (int)font.Style, Canvas.DpiY * font.Size / 72, new Point(0, 0), new StringFormat()); var matrix = new Matrix(); var matrix2 = new Matrix(); var pathBounds = path.GetBounds(); var scaleX = (float)size.Width / pathBounds.Width; var scaleY = (float)size.Height / pathBounds.Height; matrix2.Translate((float)location.X - (float)LinespacesToPixels(2.5), (float)location.Y - (float)LinespacesToPixels(2.5)); //TODO: Sprawdzić czemu się źle przesuwa i usunąć linespacestopixels matrix.Scale(scaleX, scaleY); path.Transform(matrix); path.Transform(matrix2); Canvas.DrawPath(new Pen(ConvertColor(color)), path); Canvas.FillPath(new SolidBrush(ConvertColor(color)), path); }
public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner) { }
public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { location = location.Translate(CurrentScore.DefaultPageSettings); } Typeface typeface = TypedSettings.GetFont(fontStyle); GlyphTypeface glyphTypeface; if (!typeface.TryGetGlyphTypeface(out glyphTypeface)) { return; } var glyphMap = glyphTypeface.CharacterToGlyphMap; var outline = glyphTypeface.GetGlyphOutline(glyphMap[character], 1000, 100); var path = new Path(); path.Data = outline; path.Stroke = new SolidColorBrush(ConvertColor(color)); path.Fill = new SolidColorBrush(ConvertColor(color)); path.Visibility = BoolToVisibility(owner.IsVisible); path.Stretch = Stretch.Fill; var viewBox = new Viewbox(); viewBox.Child = path; viewBox.Width = size.Width; viewBox.Height = size.Height; viewBox.Stretch = Stretch.Fill; Canvas.SetLeft(viewBox, location.X); Canvas.SetTop(viewBox, location.Y); Canvas.Children.Add(viewBox); OwnershipDictionary.Add(path, owner); }
public override void DrawStringInBounds(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner) { location = location.Translate(CurrentScore.DefaultPageSettings); TextBlock textBlock = new TextBlock(); textBlock.FontFamily = Fonts.Get(fontStyle); textBlock.FontSize = 200; textBlock.Text = text; textBlock.Margin = new Thickness(0, -25, 0, 0); textBlock.Foreground = new SolidColorBrush(ConvertColor(color)); textBlock.Visibility = BoolToVisibility(owner.IsVisible); var viewBox = new Viewbox(); viewBox.Child = textBlock; viewBox.Width = size.Width; viewBox.Height = size.Height; viewBox.Stretch = Stretch.Fill; viewBox.RenderTransform = new ScaleTransform() { ScaleX = 1, ScaleY = 1.9 }; Windows.UI.Xaml.Controls.Canvas.SetLeft(viewBox, location.X + 3d); Windows.UI.Xaml.Controls.Canvas.SetTop(viewBox, location.Y); Canvas.Children.Add(viewBox); OwnershipDictionary.Add(textBlock, owner); }
public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { location = location.Translate(CurrentScore.DefaultPageSettings); } /*var path = GetPathFromCharacter(character, fontStyle); * * path.Stroke = new SolidColorBrush(ConvertColor(color)); * path.Fill = new SolidColorBrush(ConvertColor(color)); * path.Visibility = BoolToVisibility(owner.IsVisible); * path.Stretch = Stretch.Fill; * * var viewBox = new Viewbox(); * viewBox.Child = path; * viewBox.Width = size.Width; * viewBox.Height = size.Height; * viewBox.Stretch = Stretch.Fill; * Canvas.SetLeft(viewBox, location.X); * Canvas.SetTop(viewBox, location.Y); * Canvas.Children.Add(viewBox); * * OwnershipDictionary.Add(path, owner);*/ }
public override void DrawStringInBounds(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner) { }
public static SizeF ToSizeF(this Primitives.Size size) { return(new SizeF(size.Width, size.Height)); }