Exemplo n.º 1
0
 public void IsContained(IDrawingTarget target, IDrawingBackend backend)
 {
     var c1 = backend.Ellipse(30, 10, 20, 20);
     var c2 = backend.Ellipse(25, 5, 30, 30);
     draw(target, c1, c2);
     expectRelation(c1, c2, GeometryRelation.IsContained);
 }
Exemplo n.º 2
0
 public void RotateTranslate(IDrawingTarget target)
 {
     drawOriginal(target);
     target.Translate(20, 0);
     target.Rotate(Math.PI / 8, 30, 30);
     drawTransformed(target);
 }
Exemplo n.º 3
0
 public void Arc(IDrawingTarget target)
 {
     setup(target);
     const double pi = Math.PI;
     target.Arc(0, 0, target.Width, target.Height, 0, pi / 2);
     target.Arc(0, 0, target.Width, target.Height, pi, pi * 1.5);
 }
Exemplo n.º 4
0
        public void Bezier(IDrawingTarget target)
        {
            setup(target);
            target.Bezier(0, 0, target.Width, 0, 0, target.Height, target.Width, target.Height);

            target.Report("no fill representation");
        }
Exemplo n.º 5
0
 public void StrokeFillOverlap(IDrawingTarget target, IDrawingBackend backend)
 {
     var c1 = backend.Line(30, 10, 50, 30);
     var c2 = backend.Ellipse(30, 10, 20, 20);
     draw(target, c1, c2);
     expectRelation(c1, c2, GeometryRelation.Overlap);
 }
Exemplo n.º 6
0
 public void Overlap(IDrawingTarget target, IDrawingBackend backend)
 {
     var c1 = backend.Ellipse(15, 5, 30, 30);
     var c2 = backend.Ellipse(35, 5, 30, 30);
     draw(target, c1, c2);
     expectRelation(c1, c2, GeometryRelation.Overlap);
 }
Exemplo n.º 7
0
 public void Rotated(IDrawingTarget target, IDrawingBackend backend)
 {
     var geometry = makeGeometry(backend);
     var rotated = geometry.Transform(Matrix.Rotation(-Math.PI/4, 40, 20));
     target.Fill(color: new Color(0.7, 0.7, 1));
     target.Geometry(rotated);
 }
Exemplo n.º 8
0
 public void StrokeFillIsContained(IDrawingTarget target, IDrawingBackend backend)
 {
     var c1 = backend.Line(35, 15, 45, 25);
     var c2 = backend.Ellipse(30, 10, 20, 20);
     draw(target, c1, c2);
     expectRelation(c1, c2, GeometryRelation.IsContained);
 }
Exemplo n.º 9
0
 public void StrokeFillDisjoint(IDrawingTarget target, IDrawingBackend backend)
 {
     var c1 = backend.Line(25, 10, 25, 30);
     var c2 = backend.Ellipse(30, 10, 20, 20);
     draw(target, c1, c2);
     expectRelation(c1, c2, GeometryRelation.Disjoint);
 }
Exemplo n.º 10
0
 public void Disjoint(IDrawingTarget target, IDrawingBackend backend)
 {
     var c1 = backend.Ellipse(5, 5, 30, 30);
     var c2 = backend.Ellipse(45, 5, 30, 30);
     draw(target, c1, c2);
     expectRelation(c1, c2, GeometryRelation.Disjoint);
 }
        void setup(IDrawingTarget target)
        {
            var fillColor = new Color(0, 0.5, 1);
            var strokeColor = new Color(0, 0, 0, 0.25);

            target.Fill(fillColor);
            target.Stroke(strokeColor, weight: 2);
        }
Exemplo n.º 12
0
        public void Widened(IDrawingTarget target, IDrawingBackend backend)
        {
            var geometry = makeGeometry(backend);
            var widened = geometry.Widen(6);

            target.Fill(color: new Color(0.7, 0.7, 1));
            target.Geometry(widened);
        }
Exemplo n.º 13
0
        public void Inflated(IDrawingTarget target, IDrawingBackend backend)
        {
            var geometry = makeGeometry(backend);
            var inflated = geometry.Inflate(3);

            target.Fill(color: new Color(0.7, 0.7, 1));
            target.Geometry(inflated);
        }
Exemplo n.º 14
0
        static IGeometry visualize(IDrawingTarget target, IDrawingBackend backend)
        {
            var circle = backend.Ellipse(30, 10, Diameter, Diameter);

            target.Fill(color: new Color(0.7, 0.7, 1));
            target.Geometry(circle);
            return circle;
        }
Exemplo n.º 15
0
        public void Arc(IDrawingTarget target)
        {
            setup(target);
            const double pi = Math.PI;
            target.Arc(0, 0, target.Width, target.Height, 0, pi / 2);
            target.Arc(0, 0, target.Width, target.Height, pi, pi * 1.5);

            target.Report("no fill representation");
        }
Exemplo n.º 16
0
        static void test(CombineMode mode, IDrawingTarget target, IDrawingBackend backend)
        {
            var c1 = backend.Ellipse(15, 5, 30, 30);
            var c2 = backend.Ellipse(35, 5, 30, 30);

            var r = c1.Combine(mode, c2);

            target.Fill(color: new Color(0.7, 0.7, 1.0));
            target.Geometry(r);
        }
        PixelAligningDrawingTarget(IDrawingTarget target, DrawingState state, DrawingTransform transform)
        {
            _target = target;
            _state = state;
            _transform = transform;

            _transform.Changed += transformChanged;

            transformChanged();
        }
Exemplo n.º 18
0
        public void NotContainsPoint(IDrawingTarget target, IDrawingBackend backend)
        {
            var c1 = backend.Ellipse(30, 10, 20, 20);
            var c2 = backend.Rectangle(30, 10, 1, 1);

            target.Fill(color: new Color(0.7, 0.7, 1, 0.7));
            target.Geometry(c1);
            target.Geometry(c2);

            if (c1.Contains(30, 10))
                throw new Exception("circle is not expected to contain point at 30, 10");
        }
        public static IDrawingTarget Create(IDrawingTarget target, Action disposer, DrawingState state, DrawingTransform transform)
        {
            var pixelAligner = new PixelAligningDrawingTarget(target, state, transform);

            return new DrawingTargetSplitter
                (
                    target.Backend,
                    state,
                    transform,
                    pixelAligner,
                    pixelAligner,
                    target,
                    target,
                    target, () =>
                        {
                            pixelAligner.Dispose();
                            disposer();
                        }
                    );
        }
Exemplo n.º 20
0
 public void XOR(IDrawingTarget target, IDrawingBackend backend)
 {
     test(CombineMode.XOR, target, backend);
 }
Exemplo n.º 21
0
 public void Union(IDrawingTarget target, IDrawingBackend backend)
 {
     test(CombineMode.Union, target, backend);
 }
Exemplo n.º 22
0
 public void Intersect(IDrawingTarget target, IDrawingBackend backend)
 {
     test(CombineMode.Intersect, target, backend);
 }
Exemplo n.º 23
0
 void setup(IDrawingTarget target)
 {
     target.Fill(new Color(0, 0, 0));
     target.NoStroke();
 }
Exemplo n.º 24
0
 public void RoundedRect(IDrawingTarget target)
 {
     setup(target);
     target.RoundedRectangle(0, 0, 80, 40, 8);
 }
Exemplo n.º 25
0
 public void RegularRect(IDrawingTarget target)
 {
     setup(target);
     target.Rectangle(0, 0, target.Width, target.Height);
 }
Exemplo n.º 26
0
 public void Polygon(IDrawingTarget target)
 {
     setup(target);
     target.Polygon(new double[] { 0, 0, 80, 20, 20, 40 });
 }
Exemplo n.º 27
0
 public void Ellipse(IDrawingTarget target)
 {
     setup(target);
     target.Ellipse(0, 0, target.Width, target.Height);
 }
Exemplo n.º 28
0
 static void report(IDrawingTarget target, string expected, string actual)
 {
     target.Report(expected + " expected");
     target.Report(actual + " actual");
 }
Exemplo n.º 29
0
 public void Exclude(IDrawingTarget target, IDrawingBackend backend)
 {
     test(CombineMode.Exclude, target, backend);
 }
Exemplo n.º 30
0
 static void report(IDrawingTarget target, double expected, double actual)
 {
     report(target, expected.ToString(), actual.ToString());
     var error = actual - expected;
     target.Report(error+ " error");
 }