//C++ TO C# CONVERTER TODO TASK: The implementation of the following method could not be found: // public void Dispose(); public static SKRectI GetDeviceBounds(SKRect rect, SKMatrix ctm) { SKRect device_rect = new SKRect(); SKMatrix.MapRect(ref ctm, out device_rect, ref rect); var bounds = SKRectI.Round(device_rect); return(bounds); }
/// <summary> /// Checks whether the region intersects the given rectangle. /// </summary> /// <param name="region">The region to check collision with.</param> /// <param name="rect">The rectangle to check for intersection.</param> internal static bool IntersectsRect(this SKRegion region, SKRect rect) { if (region.Bounds.IsEmpty) { return(false); } using SKRegion rectRegion = new SKRegion(); rectRegion.SetRect(SKRectI.Round(rect)); return(region.Intersects(rectRegion)); }
public void SKRectIRoundWorksAsExpected() { Assert.Equal(new SKRectI(6, 6, 21, 21), SKRectI.Round(new SKRect(5.51f, 5.51f, 20.51f, 20.51f))); Assert.Equal(new SKRectI(5, 6, 20, 21), SKRectI.Round(new SKRect(5.41f, 5.61f, 20.41f, 20.61f))); Assert.Equal(new SKRectI(20, 21, 5, 6), SKRectI.Round(new SKRect(20.41f, 20.61f, 5.41f, 5.61f))); }
protected override void OnDraw(SKImageInfo info, SKCanvas canvas) { if (CanvasSizeChanged) { _outterRect = SKRect.Create( _outterWidthRatio * info.Width / -2, _outterHeightRatio * info.Height / -2, _outterWidthRatio * info.Width, _outterHeightRatio * info.Height); } if (_firstDraw) { if (IsSquare) { float cropRectLength = Math.Min(_initCropperWidthRatio * info.Width, _initCropperHeightRatio * info.Height); _cropRect = SKRect.Create(cropRectLength / -2, cropRectLength / -2, cropRectLength, cropRectLength); } else { _cropRect = SKRect.Create( _initCropperWidthRatio * info.Width / -2, _initCropperHeightRatio * info.Height / -2, _initCropperWidthRatio * info.Width, _initCropperHeightRatio * info.Height); } _firstDraw = false; } //Draw Dim Bg using SKRegion bgRegion = new SKRegion(SKRectI.Round(_outterRect)); bgRegion.Op(SKRectI.Round(_cropRect), SKRegionOperation.Difference); canvas.DrawRegion(bgRegion, _outterRectPaint); //Draw CropRect canvas.DrawRect(_cropRect, _cropperRectPaint); //Draw Corner using SKPath cornerPath = new SKPath(); //左上角 cornerPath.MoveTo(_cropRect.Left + _cornerLength, _cropRect.Top); cornerPath.LineTo(_cropRect.Left, _cropRect.Top); cornerPath.LineTo(_cropRect.Left, _cropRect.Top + _cornerLength); //右上角 cornerPath.MoveTo(_cropRect.Right - _cornerLength, _cropRect.Top); cornerPath.LineTo(_cropRect.Right, _cropRect.Top); cornerPath.LineTo(_cropRect.Right, _cropRect.Top + _cornerLength); //左下角 cornerPath.MoveTo(_cropRect.Left + _cornerLength, _cropRect.Bottom); cornerPath.LineTo(_cropRect.Left, _cropRect.Bottom); cornerPath.LineTo(_cropRect.Left, _cropRect.Bottom - _cornerLength); //右下角 cornerPath.MoveTo(_cropRect.Right - _cornerLength, _cropRect.Bottom); cornerPath.LineTo(_cropRect.Right, _cropRect.Bottom); cornerPath.LineTo(_cropRect.Right, _cropRect.Bottom - _cornerLength); canvas.DrawPath(cornerPath, _cornerPaint); }
public static SKRectI ToSKRectI(this Rectangle rectangle) { return(SKRectI.Round(ToSKRect(rectangle))); }