示例#1
0
        public Stroke NewFromPoints(VectorsStrokeType type,
                                    CoordinateList <double> controlpoints,
                                    bool closed)
        {
            var tmp      = controlpoints.ToArray();
            int strokeID = gimp_vectors_stroke_new_from_points(_ID, type, tmp.Length,
                                                               tmp, closed);

            return(new Stroke(_ID, strokeID));
        }
示例#2
0
        Stroke AddStroke(Vectors vectors)
        {
            var controlpoints = new CoordinateList <double> {
                new Coordinate <double>(10, 10),
                new Coordinate <double>(50, 50),
                new Coordinate <double>(100, 100)
            };

            return(vectors.NewFromPoints(VectorsStrokeType.Bezier, controlpoints,
                                         true));
        }
示例#3
0
        public void Select(CoordinateList <double> segs, ChannelOps operation,
                           bool antialias, bool feather, double featherRadius)
        {
            var array = segs.ToArray();

            if (!gimp_free_select(_imageID, array.Length, array, operation,
                                  antialias, feather, featherRadius))
            {
                throw new GimpSharpException();
            }
        }
示例#4
0
        public void Add()
        {
            var list = new CoordinateList <int>();
            var c    = new Coordinate <int>(13, 14);

            list.Add(c);
            Assert.AreEqual(1, list.Count);

            list.Add(23, 24);
            Assert.AreEqual(2, list.Count);
        }
示例#5
0
        public void Equals()
        {
            var list1 = new CoordinateList <int>();
            var list2 = new CoordinateList <int>();
            var c     = new Coordinate <int>(13, 14);

            list1.Add(c);
            Assert.IsFalse(list1.Equals(list2));

            list2.Add(c);
            Assert.IsTrue(list1.Equals(list2));
        }
示例#6
0
        public void ToArray()
        {
            var list = new CoordinateList <int>();
            var c    = new Coordinate <int>(13, 14);

            int[] array = list.ToArray();
            Assert.IsNull(array);

            list.Add(c);
            array = list.ToArray();
            Assert.AreEqual(2, array.Length);
        }
示例#7
0
        public void NewFromPoints()
        {
            var vectors       = new Vectors(_image, "firstVector");
            var controlpoints = new CoordinateList <double>()
            {
                new Coordinate <double>(50, 50),
                new Coordinate <double>(100, 100),
                new Coordinate <double>(150, 150)
            };

            vectors.NewFromPoints(VectorsStrokeType.Bezier, controlpoints, false);
            Assert.AreEqual(1, vectors.Strokes.Count);
        }
示例#8
0
        // [Test]
        public void Close()
        {
            var vectors       = new Vectors(_image, "firstVector");
            var controlpoints = new CoordinateList <double>()
            {
                new Coordinate <double>(50, 50),
                new Coordinate <double>(100, 100),
                new Coordinate <double>(150, 150)
            };
            var stroke = vectors.NewFromPoints(VectorsStrokeType.Bezier,
                                               controlpoints, false);

            stroke.Close();
            bool closed;

            stroke.GetPoints(out closed);
            Assert.IsTrue(closed);
        }
示例#9
0
        public void ForEach()
        {
            var list = new CoordinateList <int>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(new Coordinate <int>(i, 2 * i));
            }

            int count = 0;

            list.ForEach(c =>
            {
                Assert.IsTrue(c == new Coordinate <int>(count, 2 * count));
                count++;
            });
            Assert.AreEqual(list.Count, count);
        }
示例#10
0
        public void Enumerator()
        {
            var list = new CoordinateList <int>();

            for (int i = 0; i < 10; i++)
            {
                list.Add(new Coordinate <int>(i, 2 * i));
            }

            int count = 0;

            foreach (var c in list)
            {
                Assert.IsTrue(c == new Coordinate <int>(count, 2 * count));
                count++;
            }
            Assert.AreEqual(list.Count, count);
        }
示例#11
0
        public void GetPoints()
        {
            var vectors       = new Vectors(_image, "firstVector");
            var controlpoints = new CoordinateList <double>()
            {
                new Coordinate <double>(50, 50),
                new Coordinate <double>(100, 100),
                new Coordinate <double>(150, 150)
            };
            var stroke = vectors.NewFromPoints(VectorsStrokeType.Bezier,
                                               controlpoints, false);
            bool closed;

            // Fix me: this one segfaults
            // var points = stroke.GetPoints(out closed);
            // Assert.AreEqual(controlpoints.Count, points.Count);
            // Assert.AreEqual(controlpoints, points);
            // Assert.IsFalse(closed);
        }
示例#12
0
        public void Scale()
        {
            var vectors       = new Vectors(_image, "firstVector");
            var controlpoints = new CoordinateList <double>()
            {
                new Coordinate <double>(50, 50),
                new Coordinate <double>(100, 100),
                new Coordinate <double>(150, 150)
            };
            var stroke = vectors.NewFromPoints(VectorsStrokeType.Bezier,
                                               controlpoints, false);
            double precision = 0.001;

            stroke.Close();
            double oldLength = stroke.GetLength(precision);

            stroke.Scale(2, 2);
            double newLength = stroke.GetLength(precision);

            Assert.IsTrue(Math.Abs(2 * oldLength - newLength) < precision);
        }
示例#13
0
 public void Select(CoordinateList <double> segs, ChannelOps operation)
 {
     Select(segs, operation, false, false, 0);
 }
示例#14
0
        public void Constructor()
        {
            var list = new CoordinateList <int>();

            Assert.AreEqual(0, list.Count);
        }