Ejemplo n.º 1
0
 public void AccessVertices()
 {
     FixedList<Vector3> vertices = new FixedList<Vector3>(CreateVertices());
       ColoredPolygon cpol = new ColoredPolygon(Color.AntiqueWhite, vertices);
       FixedList<Vector3> verts2 = new FixedList<Vector3>(CreateVertices());
       Assert.AreEqual(verts2, cpol.Vertices);
 }
Ejemplo n.º 2
0
 public void AccessColor()
 {
     List<Vector3> vertices = CreateVertices();
       Color color = Color.AliceBlue;
       ColoredPolygon cpol = new ColoredPolygon(color, vertices);
       Assert.AreEqual(Color.AliceBlue, cpol.Color);
 }
Ejemplo n.º 3
0
        public static CircleShape CreateColoredCircle(Scalar radius, ushort vertexCount)
        {
            CircleShape shape   = new CircleShape(radius, vertexCount);
            var         reduced = VertexHelper.Reduce(shape.Vertexes);
            var         polygon = new ColoredPolygon(reduced, CreateColor3Array(reduced.Length));

            shape.Tag = DrawableFactory.GetOrCreateColoredPolygonDrawable(polygon, Drawables.ShapeType.Mesh);
            return(shape);
        }
Ejemplo n.º 4
0
        public ColoredPolygonDrawable(ColoredPolygon polygon, ShapeType shapeType = ShapeType.Mesh)
        {
            if (polygon == null)
            {
                throw new ArgumentNullException("polygon");
            }

            Polygon   = polygon;
            BaseShape = shapeType;
        }
Ejemplo n.º 5
0
        protected override void DrawPolygon(Point mapPoint, ColoredPolygon polygon)
        {
            if (PictureBox == null)
            {
                return;
            }
            base.DrawPolygon(mapPoint, polygon);
            var invalidateRect = polygon.GetBoundingRectangle();

            PictureBox.Invalidate(invalidateRect);
        }
Ejemplo n.º 6
0
        public static IShape GetOrCreateColoredPolygonShape(Vector2D[] vertices, Scalar gridSpacing)
        {
            var reduced = VertexHelper.Reduce(vertices);

            var polygon = new ColoredPolygon(reduced, CreateColor3Array(reduced.Length));

            var shape = _colShapes.GetOrAdd(polygon, p => CreatePolygonShape(p, gridSpacing));

            shape.Tag = polygon;

            return(shape);
        }
        protected override void DrawPolygon(Point mapPoint, ColoredPolygon polygon)
        {
            var brush = Brushes[polygon.Color];

            try
            {
                Graphics.FillPolygon(brush, polygon.Points);
            }
            catch (InvalidOperationException ex) when(ex.Message == @"Object is currently in use elsewhere.")
            {
                // TODO: handle this in a proper way
            }
        }
Ejemplo n.º 8
0
 public void SingleYellowTriangle()
 {
     ColoredPolygon pol = new ColoredPolygon(Color.Yellow,
     v(0, 1, 2),
     v(3, 4, 5),
     v(600, 7, 8));
       ColoredPolygonMesh expected = new ColoredPolygonMesh(pol);
       string repr = @"cpl
     vertices 3
     polygons 1
     ---8<---
     0 1 2
     3 4 5
     600 7 8
     3 255 255 0 0 1 2
     ";
       ColoredPolygonMesh result = CplLoader.FromString(repr);
       Assert.AreEqual(expected, result);
 }
Ejemplo n.º 9
0
        private void DrawCell(Point point, Color color, bool disableCacheReading = false)
        {
            if (Cache)
            {
                if (!disableCacheReading)
                {
                    Color cachedColor;
                    var   exists = MapCache.TryGetValue(point, out cachedColor);
                    if (exists)
                    {
                        if (cachedColor.Equals(color))
                        {
                            return;
                        }
                    }
                }
                MapCache[point] = color;
            }
            var poly        = HexagonMode ? MapPointToHexagon(point) : MapPointToRectangle(point);
            var coloredPoly = new ColoredPolygon(poly.Points, color);

            DrawPolygon(point, coloredPoly);
        }
Ejemplo n.º 10
0
 protected override void DrawPolygon(Point mapPoint, ColoredPolygon polygon)
 {
     Polygons.Add(polygon);
 }
Ejemplo n.º 11
0
 protected abstract void DrawPolygon(Point mapPoint, ColoredPolygon polygon);
Ejemplo n.º 12
0
 public static ColoredPolygonDrawable GetOrCreateColoredPolygonDrawable(ColoredPolygon polygon, ShapeType shapeType = ShapeType.Mesh)
 {
     return(_colPolygons.GetOrAdd(polygon, p => new ColoredPolygonDrawable(p, shapeType)));
 }
Ejemplo n.º 13
0
 public void Construct()
 {
     List<Vector3> vertices = CreateVertices();
       Color color = Color.AliceBlue;
       ColoredPolygon cpol = new ColoredPolygon(color, vertices);
 }
Ejemplo n.º 14
0
 protected override void DrawPolygon(Point mapPoint, ColoredPolygon polygon)
 {
     throw new NotImplementedException();
 }