public static async Task Render(IElement element, IFrameContext context, RendererDirect2D render) { var href = element.GetHref(); if (href == null) { return; } var fragment = (href.Scheme == "internal") ? element.OwnerDocument?.GetElementById(href.Fragment.Substring(1)) : await LoadExternal(href, render, element.OwnerDocument.BaseUri); if (fragment == null) { return; } try { fragment.SetParentOverride(element); using (TransformHelper.CreatePosition(render, element, context)) await render.GetRenderer(fragment.ElementType)( fragment, context.Create(element.GetSize(context, context.Size)), render ); } finally { fragment.SetParentOverride(null); } }
public static async Task Render(IElement element, IFrameContext context, RendererDirect2D render) { var size = element.GetSize(context, context.Size); var viewPort = element.GetViewBox()?.AsRectangle() ?? size.AsRectangle(); var newContext = context.Create(viewPort.Size); using (element.IsRootElement ? null : TransformHelper.CreatePosition(render, element, context)) using (LayerHelper.Create(render, element, context, size)) using (TransformHelper.Create(render, element.GetPreserveAspectRatio().CalcMatrix(size, viewPort))) { foreach (var child in element.Children) { await render.GetRenderer(child.ElementType)(child, newContext, render); } } }
public static async Task Render(IElement element, IFrameContext context, RendererDirect2D render) { if (element.Parent.ElementType != "use") { return; } var size = element.GetSize(context, context.Size); var viewPort = element.GetViewBox()?.AsRectangle() ?? size.AsRectangle(); var newContext = context.Create(viewPort.Size); using (TransformHelper.Create(render, element.GetPreserveAspectRatio().CalcMatrix(size, viewPort))) foreach (var child in element.Children) { await render.GetRenderer(child.ElementType)(child, newContext, render); } }
public static async Task Render(this IDocument doc, IElement element, IFrameContext context, RendererDirect2D render) { var root = doc.RootElement; if (root == null) { return; } var size = element.GetSize(context, context.Size); var viewPort = root.GetViewBox()?.AsRectangle() ?? size.AsRectangle(); var newContext = context.Create(viewPort.Size); using (TransformHelper.CreatePosition(render, element, context)) using (TransformHelper.Create(render, element.GetPreserveAspectRatio().CalcMatrix(size, viewPort))) using (LayerHelper.Create(render, element, context, viewPort.Size)) foreach (var child in root.Children) { await render.GetRenderer(child.ElementType)(child, newContext, render); } }