public static Canvas Paint(Layout.LayoutBox layoutRoot, Layout.Rect bounds) { var displayList = BuildDisplayList(layoutRoot); var canvas = new Canvas((int)bounds.Width, (int)bounds.Height); foreach (var item in displayList) { canvas.PaintItem(item); } return(canvas); }
private static void RenderBorders(List <DisplayCommand> list, Layout.LayoutBox layoutBox) { var color = GetColor(layoutBox, "border-color"); if (color == null) { return; } var borderBox = layoutBox.Dimensions.BorderBox(); var rect = new Layout.Rect() { X = borderBox.X , Y = borderBox.Y , Width = layoutBox.Dimensions.Border.Left , Height = borderBox.Height }; list.Add(new SolidColor(color, rect)); rect = new Layout.Rect() { X = borderBox.X + borderBox.Width - layoutBox.Dimensions.Border.Right , Y = borderBox.Y , Width = layoutBox.Dimensions.Border.Right , Height = borderBox.Height }; list.Add(new SolidColor(color, rect)); rect = new Layout.Rect() { X = borderBox.X , Y = borderBox.Y , Width = borderBox.Width , Height = layoutBox.Dimensions.Border.Top }; list.Add(new SolidColor(color, rect)); rect = new Layout.Rect() { X = borderBox.X , Y = borderBox.Y + borderBox.Height - layoutBox.Dimensions.Border.Bottom , Width = borderBox.Width , Height = layoutBox.Dimensions.Border.Bottom }; list.Add(new SolidColor(color, rect)); }
public SolidColor(Css.Color color, Layout.Rect rect) { Color = color; Rect = rect; }