Beispiel #1
0
 void drawGeometry(iDrawContext dc, int i)
 {
     dc.fillGeometry(shapes[i], brush(i * 2 + 2));
     // dc.drawGeometry( shapes[ i ], brush( i * 2 + 1 ), strokeWidth, strokeStyle );
 }
Beispiel #2
0
        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
            }
        }
Beispiel #3
0
 void Draw.iDrawContext.fillGeometry(Draw.iGeometry path, Draw.iBrush brush)
 {
     applyTransform();
     context.fillGeometry((iGeometry)path, (iBrush)brush);
 }