コード例 #1
0
ファイル: PointListTest.cs プロジェクト: ifalvarez/complices
    private void BuildGrid()
    {
        var pointList = PoissonDisk.GeneratePoisson(ExampleUtils.ScreenRect, cellDimensions.magnitude, 10);

        grid = LineGrid <SpriteCell> .BeginShape().Segment(pointList.Count).EndShape();

        var map2D = VoronoiMap <LinePoint> .MakeMap(pointList);

        voronoiMap = map2D.To3DXY();

        foreach (var point in grid)
        {
            var     cell       = Instantiate(cellPrefab);
            Vector3 worldPoint = voronoiMap[point];

            cell.transform.parent        = root.transform;
            cell.transform.localScale    = Vector3.one;
            cell.transform.localPosition = worldPoint;

            cell.Color = ExampleUtils.Colors[ColorFunction(point)] + Color.white * 0.1f;
            cell.name  = point.ToString();

            grid[point] = cell;
        }

        ExampleUtils.PaintScreenTexture(plane, voronoiMap.To2D(), ColorFunction);
    }
コード例 #2
0
ファイル: RectWorld.cs プロジェクト: mhaque3/soa_unity
    override public void InitGrid()
    {
        var imageRect = new Rect(0, 0, heightMap.width, heightMap.height);
        var map       = new RectMap(new Vector2(40, 40));
        var map2D     = new ImageMap <RectPoint>(imageRect, Grid, map);

        foreach (var point in Grid)
        {
            int   x      = Mathf.FloorToInt(map2D[point].x);
            int   y      = Mathf.FloorToInt(map2D[point].y);
            float height = heightMap.GetPixel(x, y).r * 4;

            if (height <= 0)
            {
                height = 0.01f;
            }

            var block = Grid[point];

            if (block == null)
            {
                Debug.LogWarning("block is null " + point);
            }
            else
            {
                block.Color = ExampleUtils.Blend(height, ExampleUtils.Colors[0], ExampleUtils.Colors[1]);
                block.transform.localScale = new Vector3(1, height, 1);
            }
        }
    }
コード例 #3
0
        static void Main(string[] args)
        {
            var apiKey = ExampleUtils.GetApiKey(args);
            var client = new Client(apiKey);
            var query  = new PhoneQuery(PhoneNumber);
            Response <IPhone> response;

            try
            {
                response = client.FindPhones(query);
            }
            catch (FindException)
            {
                System.Console.Out.WriteLine("ReversePhone lookup for {0} failed!", PhoneNumber);
                throw;
            }

            if ((response != null) && (response.IsSuccess))
            {
                var results = response.Results;
                System.Console.Out.WriteLine("ReversePhone lookup for {0} was successful, returning {1} root phone objects.{2}{2}",
                                             PhoneNumber, results.Count, System.Environment.NewLine);

                foreach (var phone in results)
                {
                    ExampleUtils.DumpPhone(phone, 2);
                    System.Console.Out.WriteLine();
                }
            }

#if DEBUG
            System.Console.Out.WriteLine("Press the ENTER key to quit...");
            System.Console.In.ReadLine();
#endif
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: ShenYhan/ShadowWinform
        /// <summary>
        /// 设置调色板的颜色区间
        /// </summary>
        /// <param name="ownerSeries"></param>
        /// <param name="valueMin"></param>
        /// <param name="valueMax"></param>
        /// <returns></returns>
        private ValueRangePalette CreatePalette(IntensityGridSeries ownerSeries, double valueMin, double valueMax)
        {
            ValueRangePalette palette = new ValueRangePalette(ownerSeries);

            palette.Steps.Clear();
            ExampleUtils.DisposeAllAndClear(palette.Steps);
            double valueStep = (valueMax - valueMin) / 20.0;

            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(0, 17, 190), valueMin));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(0, 17, 190), valueMin + valueStep * 2));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(0, 151, 255), valueMin + valueStep * 3));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(0, 221, 151), valueMin + valueStep * 4));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(34, 236, 85), valueMin + valueStep * 5));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(84, 255, 51), valueMin + valueStep * 6));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(135, 255, 17), valueMin + valueStep * 7));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(169, 255, 0), valueMin + valueStep * 8));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(204, 255, 0), valueMin + valueStep * 9));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 255, 0), valueMin + valueStep * 10));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 204, 0), valueMin + valueStep * 11));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 170, 0), valueMin + valueStep * 12));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 136, 0), valueMin + valueStep * 13));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 92, 0), valueMin + valueStep * 14));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 51, 0), valueMin + valueStep * 15));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 36, 0), valueMin + valueStep * 16));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 56, 56), valueMin + valueStep * 17));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 115, 171), valueMin + valueStep * 18));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 170, 238), valueMin + valueStep * 19));
            palette.Steps.Add(new PaletteStep(palette, Color.FromArgb(255, 220, 255), valueMin + valueStep * 20));
            palette.Type     = PaletteType.Gradient;
            palette.MinValue = valueMin;

            return(palette);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            var apiKey = ExampleUtils.GetApiKey(args);
            var client = new Client(apiKey);
            var query  = new LocationQuery(StreetLine1, StreetLine2, City, StateCode, PostalCode);
            Response <ILocation> response;

            try
            {
                response = client.FindLocations(query);
            }
            catch (FindException)
            {
                System.Console.Out.WriteLine("ReverseAddress lookup for {0}; {1}; {2}; {3}; {4} failed!", StreetLine1, StreetLine2, City, StateCode, PostalCode);
                throw;
            }

            if ((response != null) && (response.IsSuccess))
            {
                var results = response.Results;
                System.Console.Out.WriteLine("ReverseAddress lookup for {0}; {1}; {2}; {3}; {4} was successful, returning {5} root location objects.{6}{6}",
                                             StreetLine1, StreetLine2, City, StateCode, PostalCode, results.Count, System.Environment.NewLine);

                foreach (var location in results)
                {
                    ExampleUtils.DumpLocation(location, 2);
                    System.Console.Out.WriteLine();
                }
            }

#if DEBUG
            System.Console.Out.WriteLine("Press the ENTER key to quit...");
            System.Console.In.ReadLine();
#endif
        }
コード例 #6
0
ファイル: LineGridTest.cs プロジェクト: mhaque3/soa_unity
    private void BuildGrid()
    {
        grid = LineGrid <SpriteCell>
               .BeginShape()
               .Segment(300)
               .EndShape();

        map2D = new ArchimedeanSpiralMap(CellDimensions, grid)
                .AnchorCellMiddleCenter()
                .WithWindow(ExampleUtils.ScreenRect)
                .AlignMiddleCenter(grid);

        map = map2D
              .To3DXY();

        foreach (var point in grid)
        {
            var cell = Instantiate(cellPrefab);

            Vector3 worldPoint = map[point];

            cell.transform.parent        = root.transform;
            cell.transform.localScale    = Vector3.one;
            cell.transform.localPosition = worldPoint;

            cell.Color = ExampleUtils.Colors[ColorFunction(point)] + Color.white * 0.2f;
            cell.name  = point.ToString();

            grid[point] = cell;
        }

        voronoiMap = new VoronoiMap <LinePoint>(grid, map2D);
        ExampleUtils.PaintScreenTexture(plane, voronoiMap, ColorFunction);
    }
コード例 #7
0
        public void InitDevice(MyAcquisitionParams acqParams = null)
        {
            _acqParams = acqParams;

            if (acqParams == null)
            {
                string[] args = new string[0];
                if (!ExampleUtils.GetOptions(args, acqParams))
                {
                    Console.WriteLine("\nPress any key to terminate\n");
                    Console.ReadKey(true);
                    return;
                }
            }



            _loc = new SapLocation(acqParams.ServerName, acqParams.ResourceIndex);
            if (SapManager.GetResourceCount(acqParams.ServerName, SapManager.ResourceType.AcqDevice) > 0)
            {
                _acqDevice = new SapAcqDevice(_loc, acqParams.ConfigFileName);
                _buffers   = new SapBufferWithTrash(2, _acqDevice, SapBuffer.MemoryType.ScatterGather);
                _transfer  = new SapAcqDeviceToBuf(_acqDevice, _buffers);

                // Create acquisition object
                if (!_acqDevice.Create())
                {
                    Console.WriteLine("Error during SapAcqDevice creation!\n");
                    DestroysObjects(null, _acqDevice, _buffers, _transfer, _view);
                    return;
                }
            }

            _transfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;
            _transfer.XferNotify        += new SapXferNotifyHandler(xfer_XferNotify);
            _transfer.XferNotifyContext  = _buffers;

            // Create buffer object
            if (!_buffers.Create())
            {
                Console.WriteLine("Error during SapBuffer creation!\n");
                DestroysObjects(null, _acqDevice, _buffers, _transfer, _view);
                return;
            }

            // Create buffer object
            if (!_transfer.Create())
            {
                Console.WriteLine("Error during SapTransfer creation!\n");
                DestroysObjects(null, _acqDevice, _buffers, _transfer, _view);
                return;
            }

            _transfer.Grab();
        }
コード例 #8
0
 static bool GetOptions(string[] args, MyAcquisitionParams acqParams)
 {
     // Check if arguments were passed
     if (args.Length > 1)
     {
         return(ExampleUtils.GetOptionsFromCommandLine(args, acqParams));
     }
     else
     {
         return(ExampleUtils.GetOptionsFromQuestions(acqParams));
     }
 }
コード例 #9
0
    private SpriteCell MakeCell(RectPoint point)
    {
        var cell = Instantiate(cellPrefab);

        cell.transform.parent        = uiRoot.transform;
        cell.transform.localScale    = Vector3.one;
        cell.transform.localPosition = map[point] + Vector3.forward;
        cell.Color       = ExampleUtils.ColorFromInt(40, 40, 40);
        cell.HighlightOn = false;
        cell.name        = "";
        return(cell);
    }
コード例 #10
0
ファイル: VoronoiMapTest.cs プロジェクト: mhaque3/soa_unity
    public void Start()
    {
        var grid = LineGrid <int>
                   .BeginShape()
                   .Segment(10)
                   .EndShape();

        var map = new ArchimedeanSpiralMap(CellDimensions, grid);

        var voronoiMap = new VoronoiMap <LinePoint>(grid, map);

        ExampleUtils.PaintScreenTexture(plane, voronoiMap, n => Mathi.Mod(n, 12));
    }
コード例 #11
0
    private void BuildGrid()
    {
        //This is the base grid, we will use it to define
        //the shape of the splice grid.
        //The contents is not important.
        var baseGrid = PointyHexGrid <bool>
                       .BeginShape()
                       .Hexagon(3)
                       .EndShape();

        //This is the base map, used for the course
        //mapping
        var baseMap = new PointyHexMap(cellDimensions)
                      .WithWindow(ExampleUtils.ScreenRect)
                      .AlignMiddleCenter(baseGrid);

        //Now we make the actual spliced grid.
        //We feed it the base grid, and the number
        //of splices we want.
        grid = new SplicedGrid <SpriteCell, PointyHexPoint>(baseGrid, spliceOffsets.Length);

        //Now we make a spliced map. This is just a one-way map --
        //it only maps grid points to the world (using the base map plus
        //splice point offsets
        var splicedMap = new SplicedMap <PointyHexPoint>(baseMap, spliceOffsets);

        //Finally, we make the above into a two way map. This map uses a Vonoroi diagram
        //to do the inverse mapping
        map = new VoronoiMap <SplicedPoint <PointyHexPoint> >(grid, splicedMap).To3DXY();

        //Then we instantiate cells as usual, and put them in our grid.
        foreach (var point in grid)
        {
            var     cell       = Instantiate(cellPrefab);
            Vector3 worldPoint = map[point];

            cell.transform.parent        = root.transform;
            cell.transform.localScale    = Vector3.one;
            cell.transform.localPosition = worldPoint;

            //slightly lighter than the DefaultColors we will use to paint the background
            cell.Color = ExampleUtils.Colors[ColorFunction(point)] + Color.white * 0.1f;
            cell.name  = point.ToString();

            grid[point] = cell;
        }

        // To make it easier to see how points are mapped, we
        ExampleUtils.PaintScreenTexture(plane, map.To2D(), ColorFunction);
    }
コード例 #12
0
    // Update is called once per frame
    void Update()
    {
        Vector3 worldPosition = ExampleUtils.ScreenToWorld(area.root, Input.mousePosition);

        worldPosition           = new Vector3(worldPosition.x, worldPosition.y, -1);
        this.transform.position = worldPosition;

        if (!Input.GetMouseButtonDown(0))
        {
            return;                                       // only destroy if we click
        }
        if (!area.grid.Contains(area.map[worldPosition]))
        {
            return;
        }

        Vector2 min = new Vector2(float.MaxValue, float.MaxValue);
        Vector2 max = new Vector2(float.MinValue, float.MinValue);

        foreach (Vector2 point in polygon.points)
        {
            min.x = Mathf.Min(min.x, point.x);
            min.y = Mathf.Min(min.y, point.y);
            max.x = Mathf.Max(max.x, point.x);
            max.y = Mathf.Max(max.y, point.y);
        }

        for (float i = min.x; i < max.x; i += area.CellDimensions.x / 2f)
        {
            for (float j = min.y; j < max.y; j += area.CellDimensions.y / 2f)
            {
                Vector3 test = transform.position + new Vector3(i, j, 0);

                if (!polygon.OverlapPoint(test))
                {
                    continue;
                }

                FlatHexPoint point = area.map[test];
                if (area.grid.Contains(point) && area.grid[point] != null)
                {
                    Destroy(area.grid[point].gameObject);
                }
            }
        }

        Use();          // adds to cooldown
    }
コード例 #13
0
        static void Main(string[] args)
        {
            var apiKey = ExampleUtils.GetApiKey(args);
            var client = new Client(apiKey);
            var query  = new PersonQuery
            {
                FirstName  = FirstName,
                MiddleName = MiddleName,
                LastName   = LastName,
                City       = City,
                StateCode  = StateCode,
                PostalCode = PostalCode,
            };

            Response <IPerson> response = null;

            try
            {
                response = client.FindPeople(query);
            }
            catch (FindException)
            {
                System.Console.Out.WriteLine("FindPerson lookup for {0}; {1}; {2}; {3}; {4}; {5} failed!", FirstName, MiddleName, LastName, City, StateCode, PostalCode);
            }

            if ((response != null) && (response.IsSuccess))
            {
                var results = response.Results;

                Console.Out.WriteLine("FindPerson lookup for {0}; {1}; {2}; {3}; {4}; {5} was successful, returning {6} root people objects{7}",
                                      FirstName, MiddleName, LastName, City, StateCode, PostalCode, results.Count, System.Environment.NewLine);

                foreach (var person in results)
                {
                    ExampleUtils.DumpPerson(person, 2);
                    System.Console.Out.WriteLine();
                }
            }

#if DEBUG
            System.Console.Out.WriteLine("Press the ENTER key to quit...");
            System.Console.In.ReadLine();
#endif
        }
コード例 #14
0
        static void Main(string[] args)
        {
            var apiKey = ExampleUtils.GetApiKey(args);
            var client = new Client(apiKey);
            var query  = new BusinessQuery
            {
                Name       = Name,
                City       = City,
                StateCode  = StateCode,
                PostalCode = PostalCode,
            };

            Response <IBusiness> response = null;

            try
            {
                response = client.FindBusinesses(query);
            }
            catch (FindException)
            {
                Console.Out.WriteLine("FindBusiness lookup for {0}; {1}; {2}; {3} failed!", Name, City, StateCode, PostalCode);
            }

            if ((response != null) && (response.IsSuccess))
            {
                var results = response.Results;
                Console.Out.WriteLine(
                    "FindBusiness lookup for {0}; {1}; {2}; {3} was successful, returning {4} root business objects{5}{5}",
                    Name, City, StateCode, PostalCode, results.Count, System.Environment.NewLine);

                foreach (var business in results)
                {
                    ExampleUtils.DumpBusiness(business, 2);
                    Console.Out.WriteLine();
                }
            }

#if DEBUG
            System.Console.Out.WriteLine("Press the ENTER key to quit...");
            System.Console.In.ReadLine();
#endif
        }
コード例 #15
0
        /**********************************************硬触发模式结束***************************************************************/


        static bool GetOptions(string[] args, MyAcquisitionParams acqParams)
        {
            return(ExampleUtils.GetOptionsFromQuestions(acqParams));
        }
コード例 #16
0
ファイル: Form1.cs プロジェクト: ShenYhan/ShadowWinform
        /// <summary>
        /// 温度云图的具体初始化细节
        /// </summary>
        private void CreateCloudChart()
        {
            _chartTempCloud = new LightningChartUltimate();

            // Disable rendering, strongly recommended before updating chart properties.
            _chartTempCloud.BeginUpdate();

            _chartTempCloud.ActiveView = ActiveView.ViewXY;
            _chartTempCloud.Parent     = lightningChartUltimate4;
            _chartTempCloud.Name       = "出铁口铁水温度分布云图";
            _chartTempCloud.Title.Text = "出铁口铁水温度分布云图";
            _chartTempCloud.Dock       = DockStyle.Fill;

            // Setup x-axis.
            _chartTempCloud.ViewXY.XAxes[0].ValueType  = AxisValueType.Number;
            _chartTempCloud.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
            _chartTempCloud.ViewXY.XAxes[0].SetRange(0, 100);
            _chartTempCloud.ViewXY.XAxes[0].Visible = false;

            // Setup y-axis.
            _chartTempCloud.ViewXY.YAxes[0].SetRange(0, 100);
            _chartTempCloud.ViewXY.YAxes[0].Visible = false;

            // Setup custom style.
            ExampleUtils.SetDarkFlatStyle(_chartTempCloud);

            // Setup legend box.
            _chartTempCloud.ViewXY.LegendBoxes[0].Layout = LegendBoxLayout.Vertical;
            _chartTempCloud.ViewXY.LegendBoxes[0].Offset = new PointIntXY(-15, -70);

            // Prepare intensity series for data.
            _intensityGrid = new IntensityGridSeries(_chartTempCloud.ViewXY, _chartTempCloud.ViewXY.XAxes[0], _chartTempCloud.ViewXY.YAxes[0]);
            _intensityGrid.ContourLineType       = ContourLineTypeXY.None;
            _intensityGrid.Optimization          = IntensitySeriesOptimization.DynamicData;
            _intensityGrid.LegendBoxUnits        = "°C";
            _intensityGrid.LegendBoxValuesFormat = "0";
            _intensityGrid.Title.Text            = "Heat map";
            _intensityGrid.MouseInteraction      = false;


            _chartTempCloud.ViewXY.IntensityGridSeries.Add(_intensityGrid);

            //Create mouse tracking point label
            _mouseTrackAnnotation                       = new AnnotationXY(_chartTempCloud.ViewXY, _chartTempCloud.ViewXY.XAxes[0], _chartTempCloud.ViewXY.YAxes[0]);
            _mouseTrackAnnotation.Fill.Color            = Color.FromArgb(0, 30, 30, 30);
            _mouseTrackAnnotation.Fill.GradientFill     = GradientFill.Solid;
            _mouseTrackAnnotation.BorderLineStyle.Color = Color.FromArgb(10, Color.White);
            //_mouseTrackAnnotation.Style = AnnotationStyle.RoundedRectangle;


            _mouseTrackAnnotation.Shadow.Visible = false;
            //_mouseTrackAnnotation.TargetCoordinateSystem = AnnotationTargetCoordinates.AxisValues;
            //annotation.Visible = false; //Don't show before the data point has been found
            _mouseTrackAnnotation.TextStyle.Color = Color.White;
            _mouseTrackAnnotation.TextStyle.Font  = new Font("Segoe UI", 15f, FontStyle.Bold);
            _mouseTrackAnnotation.Style           = AnnotationStyle.Rectangle;

            _mouseTrackAnnotation.LocationCoordinateSystem = CoordinateSystem.RelativeCoordinatesToTarget;
            _mouseTrackAnnotation.LocationRelativeOffset.SetValues(10, 10);
            _mouseTrackAnnotation.Sizing = AnnotationXYSizing.Automatic;
            _mouseTrackAnnotation.Anchor.SetValues(0, 0); //Anchor to Top-left
            _mouseTrackAnnotation.Visible          = false;
            _mouseTrackAnnotation.MouseInteraction = false;
            _chartTempCloud.ViewXY.Annotations.Add(_mouseTrackAnnotation);

            _intensityGrid.MouseInteraction = true;

            // Allow chart rendering.
            _chartTempCloud.EndUpdate();
        }
コード例 #17
0
ファイル: LaserTool.cs プロジェクト: coastwise/tojam9
    void Update()
    {
        if (!startPositionSet)
        {
            // user hasn't set the start point yet
            if (Input.GetMouseButtonDown(0))
            {
                startPoint = ExampleUtils.ScreenToWorld(area.root, Input.mousePosition);
                startPoint = new Vector3(startPoint.x, startPoint.y, -1);
                lineRenderer.SetPosition(0, startPoint);
                lineRenderer.enabled = true;
                startPositionSet     = true;
            }
        }
        else
        {
            Vector3 mouse = ExampleUtils.ScreenToWorld(area.root, Input.mousePosition);

            // fixed length lazor beam
            Vector3 delta = mouse - startPoint;
            delta = new Vector3(delta.x, delta.y, 0);

            endPoint = startPoint + delta.normalized * length;
            endPoint = new Vector3(endPoint.x, endPoint.y, -1);

            aBitLeft = Vector3.Cross(delta, Vector3.back).normalized;

            lineRenderer.SetPosition(1, endPoint);

            if (Input.GetMouseButtonDown(0) && !effect.activeSelf)
            {
                lineRenderer.enabled = false;

                TreatmentGUI.AddCooldown(type, cooldown);

                effect.SetActive(true);
                effect.transform.position = startPoint;
                iTween.MoveTo(effect, iTween.Hash("position", endPoint,
                                                  "time", 2f,
                                                  "easetype", iTween.EaseType.linear,
                                                  "oncompletetarget", this.gameObject,
                                                  "oncomplete", "ZapComplete"));
            }
        }

        if (effect.activeSelf)
        {
            FlatHexPoint testPos = area.map[effect.transform.position];
            if (area.grid[testPos] != null)
            {
                Destroy(area.grid[testPos].gameObject);
            }
            testPos = area.map[effect.transform.position + aBitLeft];
            if (area.grid[testPos] != null)
            {
                Destroy(area.grid[testPos].gameObject);
            }
            testPos = area.map[effect.transform.position - aBitLeft];
            if (area.grid[testPos] != null)
            {
                Destroy(area.grid[testPos].gameObject);
            }
            gameObject.audio.Play();
        }
    }
コード例 #18
0
ファイル: DiffusionHex.cs プロジェクト: mhaque3/soa_unity
    private void UpdateCell(PointyHexPoint point)
    {
        Color newColor = ExampleUtils.Blend(gas[point], offColor, onColor);

        Grid[point].Color = newColor;
    }