Ejemplo n.º 1
0
 /// <summary>
 /// Draw a arc
 /// </summary>
 /// <param name="spriteBatch">The destination drawing surface</param>
 /// <param name="center">The center of the arc</param>
 /// <param name="radius">The radius of the arc</param>
 /// <param name="sides">The number of sides to generate</param>
 /// <param name="startingAngle">The starting angle of arc, 0 being to the east, increasing as you go clockwise</param>
 /// <param name="radians">The number of radians to draw, clockwise from the starting angle</param>
 /// <param name="color">The color of the arc</param>
 /// <param name="thickness">The thickness of the arc</param>
 public static Action <SpriteBatch> DrawArc(Vector2 center, float radius, int sides, float startingAngle, float radians, Color color, float thickness)
 {
     return((sp) =>
     {
         List <Vector2> arc = CreateArc(radius, sides, startingAngle, radians);
         //List<Vector2> arc = CreateArc2(radius, sides, startingAngle, degrees);
         DrawPoints(center, arc, color, thickness)(sp);
     });
 }
Ejemplo n.º 2
0
        public override void LoadStatus(RSFileReader br)
        {
            base.LoadStatusCore(br);
            byte b;

            drawPoints.Clear();
            while ((b = br.ReadByte()) != 0)
            {
                switch (b)
                {
                case 20:
                    DrawPoints dp = new DrawPoints();
                    dp.penWidth = br.ReadFloat();
                    dp.penColor = br.ReadColor();
                    int i = br.ReadInt32();
                    if (i == 0)
                    {
                        dp.pts = null;
                    }
                    else
                    {
                        dp.pts = new Point[i];
                        for (int j = 0; j < i; j++)
                        {
                            dp.pts[j] = new Point(br.ReadInt32(), br.ReadInt32());
                        }
                    }
                    break;
                }
            }
        }
        public static void GetDataFromDll(int funcIdx, int rowIdx, int N, int M)
        {
            // определяем количество точек, которые будут отрисованы
            DrawPoints Data = new DrawPoints();

            Data.Count = (N + 1) * (N + 1);
            // создаем управляемое хранилище
            double[] drawpoints = new double[Data.Count * 3];

            int    sizeStruct        = Marshal.SizeOf(typeof(DrawPoints)); // определяем размер управляемой структуры
            IntPtr ptrData           = Marshal.AllocHGlobal(sizeStruct);   // выделяем память под неуправляемую структуру
            IntPtr ptrSubLevelValues = Marshal.AllocCoTaskMem(M * sizeof(double));

            Marshal.StructureToPtr(Data, ptrData, false); // копируем данные из неуправляемой в управляемую
            InitData(ptrData);
            GetData(ptrData, ptrSubLevelValues);
            Data = (DrawPoints)Marshal.PtrToStructure(ptrData, typeof(DrawPoints));

            Marshal.Copy(ptrSubLevelValues, Eque_lines[rowIdx].pQ, 0, M);
            Marshal.Copy(Data.Points, drawpoints, 0, Data.Count * 3);

            ParseReceivedData(rowIdx, drawpoints,
                              (N + 1) * (N + 1));

            Marshal.FreeHGlobal(ptrData);
            Marshal.FreeCoTaskMem(ptrSubLevelValues);
        }
Ejemplo n.º 4
0
            public DrawPoints GetPoints()
            {
                DrawPoints dp = new DrawPoints();

                dp.penWidth = penWidth;
                dp.penColor = penColor;
                dp.pts      = pts.ToArray <Point>();
                return(dp);
            }
Ejemplo n.º 5
0
 public Camera(Viewport viewport, int cameraZoomIndex, Vector2 minSize, Vector2 worldSize, bool isMiniCam)
 {
     this.viewport    = viewport;
     viewportLocation = new Vector2(viewport.X, viewport.Y);
     zoomCurrentIndex = cameraZoomIndex;
     cameraMin        = minSize;
     cameraMax        = worldSize;
     InitZoom(isMiniCam, worldSize);
     drawPoints = new DrawPoints();
 }
Ejemplo n.º 6
0
 private void ExtraObjectCollection(MapObjectsDraw mapObjectsDraw, DrawPoints drawPoints)
 {
     for (int i = 0; i < 8; i += 2)
     {
         for (int x = drawPoints.overDrawPoints[i].X; x < drawPoints.overDrawPoints[i + 1].X; x++)
         {
             for (int y = drawPoints.overDrawPoints[i].Y; y < drawPoints.overDrawPoints[i + 1].Y; y++)
             {
                 tileGrid[x, y].AddObjectToDraw(mapObjectsDraw);
             }
         }
     }
 }
Ejemplo n.º 7
0
        public void Draw(SpriteBatch spriteBatch, DrawPoints drawPoints, Camera camera, bool drawLabels, float containerFade)
        {
            //Draw Cells
            for (int x = drawPoints.topLeftPoint.X; x < drawPoints.botRightPoint.X; x++)
            {
                for (int y = drawPoints.topLeftPoint.Y; y < drawPoints.botRightPoint.Y; y++)
                {
                    miniMapCellGrid[x, y].Draw(spriteBatch, x, y, containerFade);
                }
            }

            //Draw Vehicle Circles
            if (drawVehicleCircles)
            {
                if (countUp)
                {
                    vehicleScale += 0.005f * EngineController.drawUpdateTime;
                    if (vehicleScale > 0.5)
                    {
                        countUp = false;
                    }
                }
                else
                {
                    vehicleScale -= 0.005f * EngineController.drawUpdateTime;
                    if (vehicleScale < 0.35)
                    {
                        countUp = true;
                    }
                }

                float scale = uiScale[camera.zoomCurrentIndex] * vehicleScale;

                foreach (Vehicle vehicle in miniMapVehicleList)
                {
                    Vector2 location = vehicle.GetMiniMapPosition();
                    spriteBatch.Draw(vehicleCircle.texture2D, location, vehicleCircle.location, Color.White * containerFade, 0, vehicleCircle.rotationCenter, scale, SpriteEffects.None, 0);
                }
            }

            //Draw Labels
            if (drawLabels)
            {
                float labelScale = uiScale[camera.zoomCurrentIndex];
                for (int i = 0; i < townLabels.Count; i++)
                {
                    townLabels[i].SetTextScale(labelScale);
                    townLabels[i].Draw(spriteBatch, containerFade);
                }
            }
        }
Ejemplo n.º 8
0
 public void DrawGroundLayers(SpriteBatch spriteBatch, DrawPoints drawPoints, MapObjectsDraw mapObjectsDraw)
 {
     EngineController.debugTilesOnScreen = 0;
     for (int x = drawPoints.topLeftPoint.X; x < drawPoints.botRightPoint.X; x++)
     {
         for (int y = drawPoints.topLeftPoint.Y; y < drawPoints.botRightPoint.Y; y++)
         {
             EngineController.debugTilesOnScreen++;
             tileGrid[x, y].Draw(spriteBatch);
             tileGrid[x, y].AddObjectToDraw(mapObjectsDraw);
         }
     }
     ExtraObjectCollection(mapObjectsDraw, drawPoints);
 }
    public override void onImageResults(Dictionary <int, Face> faces)
    {
        Debug.Log("Got face results");

        foreach (KeyValuePair <int, Face> pair in faces)
        {
            int  FaceId = pair.Key; // The Face Unique Id.
            Face face   = pair.Value;
            featurePointsList = face.FeaturePoints;
            // With each new update to the feature point location, we change the corresponding sphere.
            foreach (FeaturePoint fp in featurePointsList)
            {
                DrawPoints.changeSphere(fp.id, fp.x, fp.y);
            }

            // We place the sphere for the right and left eye between the 4 feature points that contour the eyes.
            DrawPoints.changeLeftEye((featurePointsList[18].x + featurePointsList[19].x + featurePointsList[32].x + featurePointsList[33].x) / 4, (featurePointsList[32].y + featurePointsList[33].y + featurePointsList[18].y + featurePointsList[19].y) / 4);
            DrawPoints.changeRightEye((featurePointsList[16].x + featurePointsList[17].x + featurePointsList[30].x + featurePointsList[31].x) / 4, (featurePointsList[16].y + featurePointsList[17].y + featurePointsList[30].y + featurePointsList[31].y) / 4);
        }
    }
Ejemplo n.º 10
0
    private void Start()
    {
        int length = this.numberOfDots * this.numberOfRings;

        Vector2[] vector2Array = new Vector2[length];
        Color32[] color32Array = new Color32[length];
        float     num          = (float)(1.0 - 0.75 / (double)length);

        for (int index = 0; index < color32Array.Length; ++index)
        {
            color32Array[index] = Color32.op_Implicit(this.dotColor);
            DrawPoints drawPoints = this;
            drawPoints.dotColor = Color.op_Multiply(drawPoints.dotColor, num);
        }
        VectorLine vectorLine = new VectorLine("Dots", new List <Vector2>((IEnumerable <Vector2>)vector2Array), this.dotSize, (LineType)2);

        vectorLine.SetColors(new List <Color32>((IEnumerable <Color32>)color32Array));
        for (int index = 0; index < this.numberOfRings; ++index)
        {
            vectorLine.MakeCircle(Vector2.op_Implicit(new Vector2((float)(Screen.get_width() / 2), (float)(Screen.get_height() / 2))), (float)(Screen.get_height() / (index + 2)), this.numberOfDots, this.numberOfDots * index);
        }
        vectorLine.Draw();
    }
Ejemplo n.º 11
0
        private void PrepareVisionProcess()
        {
            colorVideoSource = new ColorVideoSource(getVideoSource());
            colorVideoSource.ResultReady += DisplayVideo;

            // light green lines
            Hsv minColor = new Hsv(95 / 2, 0.6 * 255, 0.5 * 255);
            Hsv maxColor = new Hsv(180 / 2, 255, 0.74 * 255);

            filter = new HsvFilter(colorVideoSource, minColor, maxColor);
            roadDetector = new RoadCenterDetector(filter);
            // roadDetector.Perceptor.perspectiveTransform.ResultReady += DisplayVideo;

            // road center points, kalman filtered
            kalmanFilteredRoadCenter = new DrawColoredPointSets(roadDetector);
            kalmanFilteredRoadCenter.ResultReady += DisplayVideo;
            kalmanFilteredRoadCenter.Active = true;

            filtered = new DrawPoints(roadDetector.Perceptor.laneDetector);
            filtered.ResultReady += DisplayVideo;
            filtered.Active = true;

            visRoad = new VisualiseSimpleRoadModel(roadDetector.Perceptor.roadDetector);
            visRoad.ResultReady += DisplayVideo;

            invPerp = new PerspectiveCorrectionRgb(visRoad, CamModel.dstPerspective, CamModel.srcPerspective);
            //invPerp = new PerspectiveCorrectionRgb(colorVideoSource, CamModel.srcPerspective, CamModel.dstPerspective);
            invPerp.ResultReady += DisplayVideo;

            roadDetector.RoadCenterSupply += roadCenter;
        }