public CanvasLayer(UGContext context, float alpha, UGRect clipRect) : this(context, 2) { _context.Native.PushOpacity(alpha); var geometry = new RectangleGeometry(clipRect.ToWPFRect()); _context.Native.PushClip(geometry); }
public void OnDraw(IUGContext context) { var rect = new UGRect(10, 20, 100, 200); context.FillRoundedRectangle(rect, 40, 80, RED); context.DrawRoundedRectangle(rect, 40, 80, BLUE); var rect2 = new UGRect(); rect2.X = 4; rect2.Y = 131; rect2.Width = 10; rect2.Height = 40; context.DrawRectangle(rect2, BLUE, 2, STYLE); var points = new[] { new Vector2() { X = 10F, Y = 20F }, new Vector2() { X = 20F, Y = 10F }, new Vector2() { X = 30F, Y = 20F }, new Vector2() { X = 40F, Y = 10F }, new Vector2() { X = 50F, Y = 20F }, new Vector2() { X = 60F, Y = 10F }, }; context.DrawLines(points, BLUE); var points2 = points.Select(p => { p.Y += 30F; return(p); }).ToArray(); context.DrawLines(points2, BLUE, 2F); var points3 = points2.Select(p => { p.Y += 30F; return(p); }).ToArray(); context.DrawLines(points3, BLUE, 3F, STYLE); }
private void ComputeBounds() { #if __MACOS__ var attributes = new NSStringAttributes() { Font = _textFormat.Native, }; var size = _native.StringSize(attributes); #else var attributes = new UIStringAttributes() { Font = _textFormat.Native, }; var size = _native.GetSizeUsingAttributes(attributes); #endif _LayoutBounds = new UGRect( 0F, 0F, (float)size.Width, (float)size.Height); if (HorizontalAlignment != UGHorizontalAlignment.Left) { if (HorizontalAlignment == UGHorizontalAlignment.Right) { _LayoutBounds.X = Math.Max(0F, _requestedSize.Width - _LayoutBounds.Width); } else if (HorizontalAlignment == UGHorizontalAlignment.Center) { _LayoutBounds.X = Math.Max(0F, (_requestedSize.Width - _LayoutBounds.Width) / 2F); } } if (VerticalAlignment != UGVerticalAlignment.Top) { if (VerticalAlignment == UGVerticalAlignment.Bottom) { _LayoutBounds.Y = Math.Max(0F, _requestedSize.Height - _LayoutBounds.Height); } else if (VerticalAlignment == UGVerticalAlignment.Center) { _LayoutBounds.Y = Math.Max(0F, (_requestedSize.Height - _LayoutBounds.Height) / 2F); } } }
private void ComputeBounds() { var layout = GetLayout(); _LayoutBounds = new UGRect( 0F, 0F, layout.Width, layout.Height); if (VerticalAlignment != UGVerticalAlignment.Top) { if (VerticalAlignment == UGVerticalAlignment.Bottom) { _LayoutBounds.Y = Math.Max(0F, _requestedSize.Height - _LayoutBounds.Height); } else if (VerticalAlignment == UGVerticalAlignment.Center) { _LayoutBounds.Y = Math.Max(0F, (_requestedSize.Height - _LayoutBounds.Height) / 2F); } } }
public CanvasLayer(UGContext context, UGRect clipRect) : this(context, 1) { var geometry = new RectangleGeometry(clipRect.ToWPFRect()); _context.Native.PushClip(geometry); }
public static CGRect ToCGRect(this UGRect rect) => new CGRect(rect.X, rect.Y, rect.Width, rect.Height);
public static Rect ToWinRTRect(this UGRect rect) => new Rect(rect.X, rect.Y, rect.Width, rect.Height);
public static RectangleF ToGDIRect(this UGRect rect) => new RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
public static RectF ToAGRectF(this UGRect rect) => new RectF(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
public static Rect ToAGRect(this UGRect rect) => new Rect( (int)(rect.X + 0.5F), (int)(rect.Y + 0.5F), (int)(rect.X + rect.Width + 0.5F), (int)(rect.Y + rect.Height + 0.5F));