public NativeSkiaView(Android.Content.Context context, SkiaView skiaView) : base(context) { this.skiaView = skiaView; this.iskiaView = skiaView; this.Click += OnTapped; }
void OnLoaded(object sender, RoutedEventArgs e) { Transform = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice; Controller = new GameController(this); Controller.Startup(new FileStorage()); SkiaView.InvalidateVisual(); }
private void DrawCircle() { var skiaView = new SkiaView() { WidthRequest = 40, HeightRequest = 40 }; skiaView.OnPaintSurface = (surface, imageInfo) => { var centerX = 20; var centerY = 20; var canvas = surface.Canvas; canvas.Clear(); var fill = new SKPaint() { IsAntialias = true, Style = SKPaintStyle.Fill, Color = SKColor.Parse("#ff0000") }; canvas.DrawCircle(centerX, centerY, 20, fill); }; this.layout.Children.Add(skiaView); }
void AddImage_Clicked(System.Object sender, System.EventArgs e) { var index = _rand.Next(0, _buffer.Count()); index = 13; var im = SKImage.FromEncodedData(_buffer.ElementAt(index)).ToTextureImage(SkiaView.GRContext); var img = new MyImage() { Image = im }; if (_numberOfImages % 8 == 0) { _lastX = 0; _lastY += imagesize + _padding; } else { _lastX += imagesize + _padding; } img.Destination = new SKRect(_lastX, _lastY, _lastX + imagesize, _lastY + imagesize); _images.Add(img); _numberOfImages++; SkiaView.InvalidateSurface(); }
private void Pinch_PinchUpdated(object sender, PinchGestureUpdatedEventArgs e) { if (e.Status == GestureStatus.Started) { _startScale = _lastScale; } else if (e.Status == Xamarin.Forms.GestureStatus.Running) { _currentScale += (e.Scale - 1) * _startScale; _currentScale = Math.Max(0.003, _currentScale); _currentMatrix.ScaleX = (float)_currentScale; _currentMatrix.ScaleY = (float)_currentScale; SkiaView.InvalidateSurface(); } }
void RemoveImage_Clicked(System.Object sender, System.EventArgs e) { if (_images.Count() != 0) { _images.RemoveAt(_images.Count() - 1); _numberOfImages--; if (_numberOfImages % 5 == 0) { _lastX = 0; _lastY -= imagesize + _padding; } else { _lastX -= imagesize + _padding; } } SkiaView.InvalidateSurface(); }
void Quality_SelectedIndexChanged(System.Object sender, System.EventArgs e) { switch (QualityPicker.SelectedIndex) { case 0: _quality = SKFilterQuality.None; break; case 1: _quality = SKFilterQuality.Low; break; case 2: _quality = SKFilterQuality.Medium; break; case 3: _quality = SKFilterQuality.High; break; } SkiaView.InvalidateSurface(); }
private void SkiaView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { switch (e.ActionType) { case SkiaSharp.Views.Forms.SKTouchAction.Entered: _dragX = e.Location.X; _dragY = e.Location.Y; break; case SkiaSharp.Views.Forms.SKTouchAction.Moved: _currentMatrix.TransX = _dragX + e.Location.X; _currentMatrix.TransY = _dragY + e.Location.Y; SkiaView.InvalidateSurface(); break; case SkiaSharp.Views.Forms.SKTouchAction.Released: break; default: break; } }
private void DrawSvg() { var skiaView = new SkiaView() { WidthRequest = 125, HeightRequest = 125 }; skiaView.OnPaintSurface = (surface, imageInfo) => { using (var s = this.GetType().Assembly.GetManifestResourceStream("Samples.star.svg")) { var svg = new SkiaSharp.Extended.Svg.SKSvg(); svg.Load(s); var sx = Convert.ToSingle(skiaView.WidthRequest / svg.CanvasSize.Width); var sy = Convert.ToSingle(skiaView.HeightRequest / svg.CanvasSize.Height); var matrix = SKMatrix.MakeScale(sx, sy); surface.Canvas.DrawPicture(svg.Picture, ref matrix); } }; this.layout.Children.Add(skiaView); }
public override void Attach(SkiaView skiaView) { var viewInitialX = skiaView.X - _xToastRatio * skiaView.X; var viewInitialY = skiaView.Y - _yToastRatio * skiaView.Y; var viewInitialOpacity = skiaView.Opacity - _opacityToastRatio * skiaView.Opacity; var viewTargetX = skiaView.X; var viewTargetY = skiaView.Y; var viewTargetOpacity = skiaView.Opacity; _initialX = viewInitialX - viewTargetX; _initialY = viewInitialY - viewTargetY; _initialOpacity = viewInitialOpacity - viewTargetOpacity; _previousAnimatedOpacity = _initialOpacity; _previousAnimatedX = _initialX; _previousAnimatedY = _initialY; skiaView.X += _initialX; skiaView.Y += _initialY; skiaView.Opacity += _initialOpacity; this.Animate("toastY", p => _animatedY = (float)p, _initialY, 0, 4, _positionToastMs, Easing.CubicOut); this.Animate("toastX", p => _animatedX = (float)p, _initialX, 0, 4, _positionToastMs, Easing.CubicOut); this.Animate("toastOpacity", p => _animatedOpacity = (float)p, _initialOpacity, 0, 4, _opacityToastMs, Easing.CubicOut); Task.Run(() => { Task.Delay((int)Math.Max(_opacityToastMs, _positionToastMs)).Wait(); Dispose(); }); base.Attach(skiaView); }
private async Task DrawScaledUpImage() { if (_applyDitherBitmap == null) { return; } if (SkiaView.CanvasSize.Width > 0) { int newCanvasWidth = (int)SkiaView.CanvasSize.Width; int newCanvasHeight = (int)(SkiaView.CanvasSize.Width * (_applyDitherBitmap.Height / (double)_applyDitherBitmap.Width)); if ((int)SkiaView.CanvasSize.Width > (int)SkiaView.CanvasSize.Height) { newCanvasWidth = (int)(SkiaView.CanvasSize.Height * (_applyDitherBitmap.Width / (double)_applyDitherBitmap.Height)); newCanvasHeight = (int)SkiaView.CanvasSize.Height; } _drawBitmap = new SKBitmap(newCanvasWidth, newCanvasHeight); } _applyDitherBitmap.ScalePixels(_drawBitmap, SKFilterQuality.None); SkiaView.InvalidateSurface(); }
public void Invalidate() { SkiaView.InvalidateVisual(); }
public NativeSkiaView(SkiaView skiaView) { this.skiaView = skiaView; this.SizeChanged += OnSizeChanged; this.Tapped += OnTapped; }
public NativeSkiaView(SkiaView skiaView) { this.skiaView = skiaView; AddGestureRecognizer(new UITapGestureRecognizer(OnTapped)); }
public NativeSkiaView(SkiaView skiaView) { this.skiaView = skiaView; }
void ZoomOut_Clicked(System.Object sender, System.EventArgs e) { _currentMatrix.ScaleX -= _zoomFactor; _currentMatrix.ScaleY -= _zoomFactor; SkiaView.InvalidateSurface(); }
public virtual void Attach(SkiaView skiaView) { View = skiaView; }
public NativeSkiaView(Android.Content.Context context, SkiaView skiaView) : base(context) { _skiaView = skiaView; }
public NativeSkiaView(SkiaView skiaView) => this.skiaView = skiaView;
public NativeSkiaView(Android.Content.Context context, SkiaView skiaView) : base(context) { this.skiaView = skiaView; this.iskiaView = skiaView; this.Click += OnTapped; }
public virtual void Detach() { View = null; }
public NativeSkiaView(SkiaView skiaView) { this.skiaView = skiaView; this.SizeChanged += OnSizeChanged; }
public NativeSkiaView(Android.Content.Context context, SkiaView skiaView) : base(context) { this.skiaView = skiaView; }