public void render(iDrawContext context, Rect?box, float boundingBoxesOpacity) { Matrix3x2 view = Matrix3x2.Identity; if (viewBox.HasValue && box.HasValue) { view = MathUtils.createViewbox(box.Value, viewBox.Value); } if (boundingBoxesOpacity > 0) { boundingBoxesOpacity = MathF.Min(boundingBoxesOpacity, 1); } int i = 0; using (var t = context.transform.transform(view)) { Matrix3x2 m = paths[0].style.matrix; context.transform.push(m); Matrix3x2 transform = context.transform.current; foreach (var p in paths) { if (p.style.matrix != m) { m = p.style.matrix; context.transform.pop(); context.transform.push(m); if (boundingBoxesOpacity > 0) { transform = context.transform.current; } } if (boundingBoxesOpacity > 0) { renderBox(context, p.geometry, i++, boundingBoxesOpacity, ref transform); } int mask = 0; if (p.style.fillColor.HasValue && renderFills) { mask |= 1; } if (p.style.strokeColor.HasValue && renderStrokes) { mask |= 2; } var dev = context.device; switch (mask) { case 1: context.fillGeometry(p.geometry, dev.createSolidColorBrush(p.style.fillColor.Value)); break; case 2: context.drawGeometry(p.geometry, dev.createSolidColorBrush(p.style.strokeColor.Value), p.style.strokeWidth); break; case 3: context.fillAndStroke(p.geometry, dev.createSolidColorBrush(p.style.fillColor.Value), dev.createSolidColorBrush(p.style.strokeColor.Value), p.style.strokeWidth); break; } } // No need to pop, the `using` statement cleans up everything pushed on top of the transform stack } }
void Draw.iDrawContext.drawGeometry(Draw.iGeometry geometry, Draw.iBrush brush, float strokeWidth, Draw.iStrokeStyle strokeStyle) { applyTransform(); context.drawGeometry((iGeometry)geometry, (iBrush)brush, strokeWidth, (iStrokeStyle)strokeStyle); }