コード例 #1
0
        public override void OnBind()
        {
            base.OnBind();
            colorList = (IList <Color>)list;
            if (colorList != null)
            {
                drawLabel = false;
                height    = 30;
                c         = new ColorObject(colorList, index);
            }
            else
            {
                height = 30;
                c      = new ColorObject(memberInfo, item);
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(c))
            {
                var wrapped = UIModConfig.WrapIt(this, ref height, variable, c, order++);

                if (colorList != null)
                {
                    wrapped.Item1.Left.Pixels  -= 20;
                    wrapped.Item1.Width.Pixels += 20;
                }
            }
        }
コード例 #2
0
ファイル: ColorElement.cs プロジェクト: zyneptune/tModLoader
        public ColorElement(PropertyFieldWrapper memberInfo, object item, IList <Color> array = null, int index = -1) : base(memberInfo, item, (IList)array)
        {
            if (array != null)
            {
                drawLabel = false;
                height    = 30;
                c         = new ColorObject(array, index);
            }
            else
            {
                height = 30;
                c      = new ColorObject(memberInfo, item);
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(c))
            {
                var wrapped = UIModConfig.WrapIt(this, ref height, variable, c, order++);

                if (array != null)
                {
                    wrapped.Item1.Left.Pixels  -= 20;
                    wrapped.Item1.Width.Pixels += 20;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Add a paragraph into the specified shape with specified text
        /// </summary>
        /// <param name="shape">Represent the shape</param>
        /// <param name="text">Represent the text to be added</param>
        /// <param name="fillColor">Represent the color to fill the shape</param>
        private void AddParagraph(IShape shape, string text, IColor fillColor)
        {
            //set the fill type as solid
            shape.Fill.FillType = FillType.Solid;
            //Set the color of the solid fill
            shape.Fill.SolidFill.Color = fillColor;
            //set the fill type of line format as solid
            shape.LineFormat.Fill.FillType = FillType.Solid;
            //set the fill color of line format
            if (fillColor.R == 255)
            {
                shape.LineFormat.Fill.SolidFill.Color = ColorObject.FromArgb(190, 100, 39);
            }
            else
            {
                shape.LineFormat.Fill.SolidFill.Color = ColorObject.FromArgb(54, 91, 157);
            }
            //Add a paragraph into the specified shape with specified text
            IParagraph paragraph = shape.TextBody.AddParagraph(text);

            //Set the vertical alignment as center
            shape.TextBody.VerticalAlignment = VerticalAlignmentType.Middle;
            //Set horizontal alignment as center
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            //Set font color as white
            paragraph.Font.Color = ColorObject.White;
            //Change the font size
            paragraph.Font.FontSize = 16;
        }
コード例 #4
0
    public void createSugarRibs(float RibbonsThickness, bool sugarOnly, float thickness_Little, float thickness_BIG,
                                float thickness_bond_6_C1_C4, float thickness_6_other, float thickness_bond_5,
                                float lighter_color_factor_ring, float lighter_color_factor_bond, int color_mode_ring, int color_mode_bond,
                                ColorObject bondcolor, ColorObject ringcolor, float OxySphereSize, ColorObject OxySphereColor)
    {
        sugarResname.AddMany("ABE", "ACE", "ALT", "API", "ARA", "DHA", "FRU", "FUC", "GAL", "GLC", "GUL", "IDO", "DKN", "KDO", "MAN", "NEG", "RHA", "RIB", "SIA", "TAG", "TAL", "XYL");
        SUGAR_ONLY                = sugarOnly;
        THICKNESS_LITTLE_MESH     = thickness_Little;
        THICKNESS_BIG_MESH        = thickness_BIG;
        THICKNESS_BOND_6_C1_C4    = thickness_bond_6_C1_C4;
        THICKNESS_BOND_6_OTHER    = thickness_6_other;
        THICKNESS_BOND_5          = thickness_bond_5;
        LIGHTER_COLOR_FACTOR_RING = lighter_color_factor_ring;
        LIGHTER_COLOR_FACTOR_BOND = lighter_color_factor_bond;
        COLOR_MODE_RING           = color_mode_ring;
        COLOR_MODE_BOND           = color_mode_bond;
        BONDCOLOR      = bondcolor;
        RINGCOLOR      = ringcolor;
        OXYSPHERESIZE  = OxySphereSize;
        OXYSPHERECOLOR = OxySphereColor;
        THICKNESS      = RibbonsThickness;
        //We initialize all vertex (an atom is a vertex here)


        createSugarRibbons();
        /* we finaly draw all mesh, now that we detect all cycle in the molecule*/
    }     /* End of CreateTwister*/
コード例 #5
0
    public ColorOption GetColor(ColorObject playerControlInput)
    {
        // When player inputs a control, check its color and assign it a ColorOptions value,
        // TBD: Used for comparing against colorPrompt.

        Color color = playerControlInput.GetComponent <MeshRenderer>().material.color;

        playerControlInput.currentColor = ColorOption.invalid;

        if (color == Color.red)
        {
            playerControlInput.currentColor = ColorOption.red;
        }
        if (color == Color.blue)
        {
            playerControlInput.currentColor = ColorOption.blue;
        }
        if (color == Color.yellow)
        {
            playerControlInput.currentColor = ColorOption.yellow;
        }
        if (color == Color.green)
        {
            playerControlInput.currentColor = ColorOption.green;
        }

        if (!GameManager.Instance.isBetweenRounds)
        {
            playerControlInput.FlashButtonLight();
        }

        return(playerControlInput.currentColor);
    }
コード例 #6
0
    private void Start()
    {
        particles     = GetComponentsInChildren <ParticleSystem>();
        mover         = GetComponent <Mover>();
        _colorObject  = GetComponent <ColorObject>();
        _colorChanger = GetComponent <ColorChanger>();
        //FMODUnity.RuntimeManager.PlayOneShot("event:/Train/Engine");

        chuuSound = FMODUnity.RuntimeManager.CreateInstance("event:/Train/Chuu");
        chuuSound.getParameter("ChuuActive", out chuuActive);

        engineSound = FMODUnity.RuntimeManager.CreateInstance("event:/Train/Engine");
        engineSound.getParameter("GameSpeed", out engineSpeed);

        musicSound = FMODUnity.RuntimeManager.CreateInstance("event:/Music/Saloon");
        musicSound.getParameter("GameSpeed", out musicSpeed);

        engineSpeed.setValue(0.05f);
        musicSpeed.setValue(0.2f);

        engineSound.setVolume(EngineVolume);


        engineSound.start();
        musicSound.setVolume(MusicVolume);
        musicSound.start();
    }
コード例 #7
0
ファイル: PlayerScript.cs プロジェクト: shovelandsandbox/dash
    void OnTriggerEnter2D(Collider2D collision)
    {
        ColorObject enemyColorObject = collision.gameObject.GetComponent <ColorObject>();

        if (enemyColorObject != null)
        {
            if (!getColor().Equals(enemyColorObject.getColor()))
            {
                if (collision.gameObject.transform.rotation.eulerAngles.z != 0)
                {
                    BoxCollider2D collider = collision.gameObject.GetComponent <BoxCollider2D>();
                    collider.isTrigger = false;
                }
                else
                {
                    Destroy(gameObject);
                }
            }
            else
            {
                gatesPassed++;
                BeatsEngine.Instance.gateDestroyed();
            }
            //Destroy(collision.gameObject);
        }
    }
コード例 #8
0
ファイル: ColorElement.cs プロジェクト: 13784884462/tML1.4
        public override void OnBind()
        {
            base.OnBind();
            colorList = (IList <Color>)list;
            if (colorList != null)
            {
                drawLabel = false;
                height    = 30;
                c         = new ColorObject(colorList, index);
            }
            else
            {
                height = 30;
                c      = new ColorObject(memberInfo, item);
            }

            // TODO: Draw the sliders in the same manner as vanilla.
            var  colorHSLSliderAttribute = ConfigManager.GetCustomAttribute <ColorHSLSliderAttribute>(memberInfo, item, list);
            bool useHue = colorHSLSliderAttribute != null;
            bool showSaturationAndLightness = colorHSLSliderAttribute?.showSaturationAndLightness ?? false;
            bool noAlpha = ConfigManager.GetCustomAttribute <ColorNoAlphaAttribute>(memberInfo, item, list) != null;

            List <string> skip = new List <string>();

            if (noAlpha)
            {
                skip.Add(nameof(ColorObject.A));
            }
            if (useHue)
            {
                skip.AddRange(new[] { nameof(ColorObject.R), nameof(ColorObject.G), nameof(ColorObject.B) });
            }
            else
            {
                skip.AddRange(new[] { nameof(ColorObject.Hue), nameof(ColorObject.Saturation), nameof(ColorObject.Lightness) });
            }
            if (useHue && !showSaturationAndLightness)
            {
                skip.AddRange(new[] { nameof(ColorObject.Saturation), nameof(ColorObject.Lightness) });
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(c))
            {
                if (skip.Contains(variable.Name))
                {
                    continue;
                }

                var wrapped = UIModConfig.WrapIt(this, ref height, variable, c, order++);

                if (colorList != null)
                {
                    wrapped.Item1.Left.Pixels  -= 20;
                    wrapped.Item1.Width.Pixels += 20;
                }
            }
        }
コード例 #9
0
 public static void CreateColorPicker(ColorObject col, string title, List <string> atomTarget, string residueTarget = "All", string chainTarget = "All")
 {
     if (m_colorPicker != null)
     {
         m_colorPicker = null;
     }
     m_colorPicker = new ColorPicker(Rectangles.colorPickerRect, col, atomTarget, residueTarget, chainTarget, title);
 }
コード例 #10
0
 private void btnCreateImage_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //Opens the existing presentation stream.
         using (IPresentation presentation = Presentation.Create())
         {
             ISlide     slide     = presentation.Slides.Add(SlideLayoutType.TitleOnly);
             IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
             //Apply center alignment to the paragraph
             paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
             //Add slide title
             ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
             textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
             //Get chart data from xml file
             DataSet dataSet = new DataSet();
             dataSet.ReadXml(@"..\..\..\..\..\..\..\Common\Data\Presentation\Products.xml");
             //Add a new chart to the presentation slide
             IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
             //Set chart type
             chart.ChartType = OfficeChartType.Pie;
             //Set chart title
             chart.ChartTitle = "Best Selling Products";
             //Set chart properties font name and size
             chart.ChartTitleArea.FontName = "Calibri (Body)";
             chart.ChartTitleArea.Size     = 14;
             for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
             {
                 chart.ChartData.SetValue(i + 2, 1, dataSet.Tables[0].Rows[i].ItemArray[1]);
                 chart.ChartData.SetValue(i + 2, 2, dataSet.Tables[0].Rows[i].ItemArray[2]);
             }
             //Create a new chart series with the name “Sales”
             AddSeriesForChart(chart);
             //Setting the font size of the legend.
             chart.Legend.TextArea.Size = 14;
             //Setting background color
             chart.ChartArea.Fill.ForeColor           = System.Drawing.Color.FromArgb(242, 242, 242);
             chart.PlotArea.Fill.ForeColor            = System.Drawing.Color.FromArgb(242, 242, 242);
             chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
             chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
             //Saves the presentation instance to the stream.
             presentation.Save("ChartCreationSample.pptx");
             if (System.Windows.MessageBox.Show("Do you want to view the generated PowerPoint Presentation?", "Chart Creation",
                                                MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 System.Diagnostics.Process.Start("ChartCreationSample.pptx");
                 this.Close();
             }
         }
     }
     catch (Exception exception)
     {
         System.Windows.MessageBox.Show("This Presentation could not be created, please contact Syncfusion Direct-Trac system at http://www.syncfusion.com/support/default.aspx for any queries. ", "OOPS..Sorry!",
                                        MessageBoxButton.OK);
         this.Close();
     }
 }
コード例 #11
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            MemoryStream stream = new MemoryStream();

            //Create a Presentation instance
            using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create())
            {
                //Add a blank slide to the Presentation
                ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                //Add a empty paragraph to the slide
                IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
                //Apply center alignment to the paragraph
                paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                //Add slide title
                ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
                textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
                //Get chart data from xml file
                List <ProductDetails> Products = LoadXMLData();
                //Add a new chart to the presentation slide
                IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
                //Set chart type
                chart.ChartType = OfficeChartType.Pie;
                //Set chart title
                chart.ChartTitle = "Best Selling Products";
                //Set chart properties font name and size
                chart.ChartTitleArea.FontName = "Calibri (Body)";
                chart.ChartTitleArea.Size     = 14;
                //Itterate and set the values to chart
                for (int i = 0; i < Products.Count; i++)
                {
                    ProductDetails product = Products[i];
                    chart.ChartData.SetValue(i + 2, 1, product.ProductName);
                    chart.ChartData.SetValue(i + 2, 2, product.Sum);
                }
                //Create a new chart series with the name �Sales�
                AddSeriesForChart(chart);
                //Set the font size of the legend.
                chart.Legend.TextArea.Size = 14;
                //Set the color formatting to the chart
                chart.ChartArea.Fill.ForeColor           = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.PlotArea.Fill.ForeColor            = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
                chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
                //Save the presentation instance to a stream.
                presentation.Save(stream);
            }
            stream.Position = 0;
            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("ChartsSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("ChartsSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
        }
コード例 #12
0
 void ThrowApple()
 {
     stackTop = stack.TopApple();
     if (stackTop)
     {
         AudioManager.Instance.PlayEffectAt(17, transform.position, 0.081f);
         AudioManager.Instance.PlayEffectAt(5, transform.position, 0.073f);
         anim.SetTrigger("eat");
     }
 }
コード例 #13
0
 public ActionResult ShowCase(IFormCollection collection)
 {
     _showcaseOption.LoadPostData(collection);
     ViewBag.DemoOptions = _showcaseOption;
     ViewBag.Countries   = FullCountry.GetCountries();
     ViewBag.Products    = ProductObject.GetProductObjects();
     ViewBag.Colors      = ColorObject.GetColorObjects();
     Theme.SetCurrentTheme(HttpContext, Themes.CleanLight);
     return(View(model));
 }
コード例 #14
0
 // Use this for initialization
 void Start()
 {
     foreach (Transform child in this.transform)
     {
         _childKey = child.GetComponent<ColorObject>();
         if (_childKey)
             break;
     }
     if (!_childKey)
         Debug.Log("UnableToFindKey");
 }
コード例 #15
0
ファイル: GameManager.cs プロジェクト: karikai/Buttons
    void initializeColor()
    {
        Color[] randomColors = { Color.red, Color.blue, Color.cyan, Color.green, Color.magenta };
        Color   randomColor  = randomColors[Random.Range(1, 5)];

        this.colorList      = new LinkedList <ColorObject>();
        this.correctColorId = 1;
        ColorObject newColor = new ColorObject(randomColor, 1);

        this.colorList.AddFirst(newColor);
    }
コード例 #16
0
        public IActionResult CreateSlide(string image, string header, string content)
        {
            WebClient webClient = new WebClient();

            webClient.DownloadFile(image, "image.jpg");

            //Create a new instance of PowerPoint Presentation file
            IPresentation pptxDoc = Presentation.Create();

            //Add a new slide to file and apply background color
            ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.TitleOnly);

            //Specify the fill type and fill color for the slide background
            slide.Background.Fill.FillType        = FillType.Solid;
            slide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(232, 241, 229);

            //Add title content to the slide by accessing the title placeholder of the TitleOnly layout-slide
            IShape titleShape = slide.Shapes[0] as IShape;

            titleShape.TextBody.AddParagraph(header).HorizontalAlignment = HorizontalAlignmentType.Center;

            //Add description content to the slide by adding a new TextBox
            IShape descriptionShape = slide.AddTextBox(53.22, 141.73, 874.19, 77.70);

            descriptionShape.TextBody.Text = content;

            //Gets a picture as stream.
            FileStream pictureStream = new FileStream("image.jpg", FileMode.Open);

            //Adds the picture to a slide by specifying its size and position.
            slide.Shapes.AddPicture(pictureStream, 499.79, 238.59, 364.54, 192.16);

            //Save the PowerPoint Presentation as stream
            FileStream outputStream = new FileStream("Sample.pptx", FileMode.Create);

            pptxDoc.Save(outputStream);

            //Release all resources from stream
            outputStream.Dispose();

            //Close the PowerPoint presentation
            pptxDoc.Close();

            var displaySlide = new Result
            {
                Title   = header,
                Content = content,
                Link    = image
            };

            return(View(displaySlide));
        }
コード例 #17
0
ファイル: GameManager.cs プロジェクト: karikai/Buttons
    // Color Picker Functions

    void GenerateRandomColors()
    {
        Color[] randomColors = { Color.red, Color.blue, Color.cyan, Color.green, Color.magenta };

        this.correctColorId = Random.Range(1, GetNumberOfOrbs() + 1);

        for (int i = 0; i < GetNumberOfOrbs(); i++)
        {
            Color       randomColor = randomColors[i];
            ColorObject newColor    = new ColorObject(randomColor, i + 1);
            this.colorList.AddFirst(newColor);
        }
    }
コード例 #18
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            MemoryStream stream = new MemoryStream();

            //Opens the existing presentation stream.
            using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create())
            {
                ISlide     slide     = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
                //Apply center alignment to the paragraph
                paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                //Add slide title
                ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
                textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
                //Get chart data from xml file
                List <ProductDetails> Products = LoadXMLData();
                //Add a new chart to the presentation slide
                IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
                //Set chart type
                chart.ChartType = OfficeChartType.Pie;
                //Set chart title
                chart.ChartTitle = "Best Selling Products";
                //Set chart properties font name and size
                chart.ChartTitleArea.FontName = "Calibri (Body)";
                chart.ChartTitleArea.Size     = 14;
                for (int i = 0; i < Products.Count; i++)
                {
                    ProductDetails product = Products[i];
                    chart.ChartData.SetValue(i + 2, 1, product.ProductName);
                    chart.ChartData.SetValue(i + 2, 2, product.Sum);
                }
                //Create a new chart series with the name “Sales”
                AddSeriesForChart(chart);
                //Setting the font size of the legend.
                chart.Legend.TextArea.Size = 14;
                //Setting background color
                chart.ChartArea.Fill.ForeColor           = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.PlotArea.Fill.ForeColor            = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
                chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
                //Saves the presentation instance to the stream.
                presentation.Save(stream);
            }
            stream.Position = 0;

            if (stream != null)
            {
                SaveiOS iOSSave = new SaveiOS();
                iOSSave.Save("ChartsPresentation.pptx", "application/mspowerpoint", stream);
            }
        }
コード例 #19
0
ファイル: Misc.cs プロジェクト: tekintr/Elobuddy
        public static Color SharpDxColorFromHsv(this HsvColor c)
        {
            var hue        = c.Hue;
            var saturation = c.Saturation;
            var brightness = c.Value;

            if (hue > 360 || hue < 0 || saturation > 1 || saturation < 0 || brightness > 1 || brightness < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            var         chroma = brightness * saturation;
            var         x      = chroma * (1 - Math.Abs(hue / 60f % 2 - 1));
            var         m      = brightness - chroma;
            ColorObject color;

            if (0 <= hue && 60 > hue)
            {
                color = new ColorObject(chroma, x, 0);
            }
            else if (60 <= hue && 120 > hue)
            {
                color = new ColorObject(x, chroma, 0);
            }
            else if (120 <= hue && 180 > hue)
            {
                color = new ColorObject(0, chroma, x);
            }
            else if (180 <= hue && 240 > hue)
            {
                color = new ColorObject(0, x, chroma);
            }
            else if (240 <= hue && 300 > hue)
            {
                color = new ColorObject(x, 0, chroma);
            }
            else if (300 <= hue && 360 > hue)
            {
                color = new ColorObject(chroma, 0, x);
            }
            else
            {
                color = new ColorObject(0, 0, 0);
            }

            color.R = (color.R + m) * 255;
            color.G = (color.G + m) * 255;
            color.B = (color.B + m) * 255;

            return(new Color(Convert.ToInt32(color.R), Convert.ToInt32(color.G), Convert.ToInt32(color.B), 255));
        }
コード例 #20
0
ファイル: Misc.cs プロジェクト: tekintr/Elobuddy
        public static System.Drawing.Color ColorFromHsv(double hue, double saturation, double brightness)
        {
            if (hue > 360 || hue < 0 || saturation > 1 || saturation < 0 || brightness > 1 || brightness < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            var         chroma = brightness * saturation;
            var         x      = chroma * (1 - Math.Abs(hue / 60f % 2 - 1));
            var         m      = brightness - chroma;
            ColorObject color;

            if (0 <= hue && 60 > hue)
            {
                color = new ColorObject(chroma, x, 0);
            }
            else if (60 <= hue && 120 > hue)
            {
                color = new ColorObject(x, chroma, 0);
            }
            else if (120 <= hue && 180 > hue)
            {
                color = new ColorObject(0, chroma, x);
            }
            else if (180 <= hue && 240 > hue)
            {
                color = new ColorObject(0, x, chroma);
            }
            else if (240 <= hue && 300 > hue)
            {
                color = new ColorObject(x, 0, chroma);
            }
            else if (300 <= hue && 360 > hue)
            {
                color = new ColorObject(chroma, 0, x);
            }
            else
            {
                color = new ColorObject(0, 0, 0);
            }

            color.R = (color.R + m) * 255;
            color.G = (color.G + m) * 255;
            color.B = (color.B + m) * 255;

            return(System.Drawing.Color.FromArgb(255, Convert.ToInt32(color.R), Convert.ToInt32(color.G), Convert.ToInt32(color.B)));
        }
コード例 #21
0
    public void UpdateColor(GameObject colorGO)
    {
        ColorOption inputColor     = 0;
        ColorOption newColorOption = 0;
        Material    targetMaterial = colorGO.GetComponent <MeshRenderer>().material;

        // Check which type of input we received NOTE: this is now redundant. Only used for prompt.
        if (colorGO == colorPromptGO) // update prompt material
        {
            // Should probably make this into its own method.
            inputColor = PlayerController.Instance.DisplayRandomColor();
            ColorObject colorObject = colorGO.GetComponent <ColorObject>();
            newColorOption           = RandomizeColor();
            colorObject.currentColor = newColorOption;
            colorObject.LightColorPrompt();
        }

        Color newColor = Color.black;

        switch (newColorOption)
        {
        case ColorOption.blue:
            newColor = Color.blue;
            break;

        case ColorOption.green:
            newColor = Color.green;
            break;

        case ColorOption.red:
            newColor = Color.red;
            break;

        case ColorOption.yellow:
            newColor = Color.yellow;
            break;

        case ColorOption.invalid:
            Debug.LogWarning("Invalid color!");
            break;
        }

        if (targetMaterial.color != newColor)
        {
            targetMaterial.color = newColor;
        }
    }
コード例 #22
0
        private void CreateInitialPPt()
        {
            String Title, TextDesc;

            Title    = Title_txtBx.Text;
            TextDesc = Txt_Blk.Text;
            string today = DateTime.Now.ToShortDateString();

            //Creates a new ppt doc
            IPresentation ppt_doc = Presentation.Create();

            //Adding a initial slide to the ppt
            ISlide slide = ppt_doc.Slides.Add(SlideLayoutType.PictureWithCaption);

            //Specify the fill type and fill color for the slide background
            slide.Background.Fill.FillType        = FillType.Solid;
            slide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(232, 241, 229);

            //Add title content to the slide by accessing the title placeholder of the TitleOnly layout-slide
            IShape titleShape = slide.Shapes[0] as IShape;

            titleShape.TextBody.AddParagraph(Title).HorizontalAlignment = HorizontalAlignmentType.Center;

            //Adding a TextBox to the slide
            IShape shape = slide.AddTextBox(80, 200, 500, 100);

            shape.TextBody.AddParagraph(TextDesc);

            String imgName = GetImageName();

            imgName = staticFilePath + imgName;
            //Gets a picture as stream.
            Stream pictureStream = File.Open(imgName, FileMode.Open);

            //Adds the picture to a slide by specifying its size and position.
            slide.Shapes.AddPicture(pictureStream, 499.79, 238.59, 364.54, 192.16);

            //Save the ppt
            ppt_doc.Save(Title + ".pptx");

            //Dispose the image stream
            pictureStream.Dispose();

            //closing the ppt
            ppt_doc.Close();
        }
        public ActionResult CreatingChart(string Browser)
        {
            IPresentation presentation = Presentation.Create();
            ISlide        slide        = presentation.Slides.Add(SlideLayoutType.TitleOnly);
            IParagraph    paragraph    = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();

            //Apply center alignment to the paragraph
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            //Add slide title
            ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");

            textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
            //Get chart data from xml file
            DataSet dataSet = new DataSet();
            //Load XML file
            string dataPath = ResolveApplicationDataPath("Products.xml");

            dataSet.ReadXml(dataPath);
            //Add a new chart to the presentation slide
            IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);

            //Set chart type
            chart.ChartType = OfficeChartType.Pie;
            //Set chart title
            chart.ChartTitle = "Best Selling Products";
            //Set chart properties font name and size
            chart.ChartTitleArea.FontName = "Calibri (Body)";
            chart.ChartTitleArea.Size     = 14;
            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                chart.ChartData.SetValue(i + 2, 1, dataSet.Tables[0].Rows[i].ItemArray[1]);
                chart.ChartData.SetValue(i + 2, 2, dataSet.Tables[0].Rows[i].ItemArray[2]);
            }
            //Create a new chart series with the name �Sales�
            AddSeriesForChart(chart);
            //Setting the font size of the legend.
            chart.Legend.TextArea.Size = 14;
            //Setting background color
            chart.ChartArea.Fill.ForeColor           = System.Drawing.Color.FromArgb(242, 242, 242);
            chart.PlotArea.Fill.ForeColor            = System.Drawing.Color.FromArgb(242, 242, 242);
            chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
            //  Saves the presentation
            return(new PresentationResult(presentation, "Chart.pptx", HttpContext.ApplicationInstance.Response));
        }
コード例 #24
0
 public ColorPicker(Rect r,
                    ColorObject colorObj, List <string> atoms, string residue = "All", string chain = "All",
                    string title = "Color Picker", int caller = -1)
 {
     m_colorObj   = colorObj;
     m_atoms      = atoms;
     m_residue    = residue;
     m_chain      = chain;
     m_r_value    = (int)(colorObj.color.r * 255f);
     m_g_value    = (int)(colorObj.color.g * 255f);
     m_b_value    = (int)(colorObj.color.b * 255f);
     m_rect       = r;
     m_aTexture   = (Texture2D)Resources.Load("ImprovedColorPicker");
     m_title      = title;
     this.enabled = true;
     m_activeArea = new Rect(m_rect.x + m_text_area.x, m_rect.y + m_text_area.y, m_text_area.width, m_text_area.height);
     callId       = caller;
 }
コード例 #25
0
    /***********************************************
    ************** TOOL FUNCTIONS *****************
    ***********************************************/

    public void updateColor(string tag, ColorObject newColor)
    {
        GameObject[] objs = GameObject.FindGameObjectsWithTag(tag);
        for (int i = 0; i < objs.Length; i++)
        {
            Color32[] colours = objs[i].GetComponent <MeshFilter> ().mesh.colors32;

            for (int j = 0; j < colours.Length; j++)
            {
                if (tag == "SugarRibbons_BOND")
                {
                    colours[j] = lightColor(newColor.color, LIGHTER_COLOR_FACTOR_BOND);
                }
                else
                {
                    colours[j] = lightColor(newColor.color, LIGHTER_COLOR_FACTOR_RING);
                }
            }
            objs[i].GetComponent <MeshFilter> ().mesh.colors32 = colours;
        }
    }
コード例 #26
0
 void Update()
 {
     try
     {
         ColorObject colorObject = sample.MaxItems[name];
         if (sample.MaxItems[name] == null)
         {
             transform.position = Vector3.one * 1000;
             return;
         }
         float   prop      = (float)sample.webCamTexture.height / (float)Screen.height;
         int     xMyScreen = Mathf.RoundToInt(((float)colorObject.XPos / (float)sample.webCamTexture.width) * (float)Screen.width);
         int     yMyScreen = Mathf.RoundToInt(((float)colorObject.YPos / (float)sample.webCamTexture.height) * (float)Screen.height);
         Vector3 pos       = Camera.main.ScreenToWorldPoint(new Vector3(xMyScreen, yMyScreen, 0));
         transform.position   = new Vector3(pos.x, -pos.y * prop, -5);
         transform.localScale = new Vector3((float)Math.Sqrt(colorObject.Area), (float)Math.Sqrt(colorObject.Area), 1);
         if (colorObject.Area > 0)
         {
             transform.Rotate(0, 0, 5);
         }
     }
     catch (Exception) { }
 }
コード例 #27
0
        public ActionResult Connector(string Browser)
        {
            //Create an instance for PowerPoint
            IPresentation presentation = Syncfusion.Presentation.Presentation.Create();

            //Add a blank slide to Presentation
            ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);

            //Add header shape
            IShape headerTextBox = slide.Shapes.AddTextBox(58.44, 53.85, 221.93, 81.20);
            //Add a paragraph into the text box
            IParagraph paragraph = headerTextBox.TextBody.AddParagraph("Flow chart with ");
            //Add a textPart
            ITextPart textPart = paragraph.AddTextPart("Connector");

            //Change the color of the font
            textPart.Font.Color = ColorObject.FromArgb(44, 115, 230);
            //Make the textpart bold
            textPart.Font.Bold = true;
            //Set the font size of the paragraph
            paragraph.Font.FontSize = 28;

            //Add start shape to slide
            IShape startShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 36.35, 133.93, 50.39);

            //Add a paragraph into the start shape text body
            AddParagraph(startShape, "Start", ColorObject.FromArgb(255, 149, 34));

            //Add alarm shape to slide
            IShape alarmShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 126.72, 133.93, 50.39);

            //Add a paragraph into the alarm shape text body
            AddParagraph(alarmShape, "Alarm Rings", ColorObject.FromArgb(255, 149, 34));

            //Add condition shape to slide
            IShape conditionShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDecision, 420.45, 222.42, 133.93, 97.77);

            //Add a paragraph into the condition shape text body
            AddParagraph(conditionShape, "Ready to Get Up ?", ColorObject.FromArgb(44, 115, 213));

            //Add wake up shape to slide
            IShape wakeUpShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 361.52, 133.93, 50.39);

            //Add a paragraph into the wake up shape text body
            AddParagraph(wakeUpShape, "Wake Up", ColorObject.FromArgb(44, 115, 213));

            //Add end shape to slide
            IShape endShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 453.27, 133.93, 50.39);

            //Add a paragraph into the end shape text body
            AddParagraph(endShape, "End", ColorObject.FromArgb(44, 115, 213));

            //Add snooze shape to slide
            IShape snoozeShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 624.85, 245.79, 159.76, 50.02);

            //Add a paragraph into the snooze shape text body
            AddParagraph(snoozeShape, "Hit Snooze button", ColorObject.FromArgb(255, 149, 34));

            //Add relay shape to slide
            IShape relayShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDelay, 624.85, 127.12, 159.76, 49.59);

            //Add a paragraph into the relay shape text body
            AddParagraph(relayShape, "Relay", ColorObject.FromArgb(255, 149, 34));

            //Connect the start shape with alarm shape using connector
            IConnector connector1 = slide.Shapes.AddConnector(ConnectorType.Straight, startShape, 2, alarmShape, 0);

            //Set the arrow style for the connector
            connector1.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the alarm shape with condition shape using connector
            IConnector connector2 = slide.Shapes.AddConnector(ConnectorType.Straight, alarmShape, 2, conditionShape, 0);

            //Set the arrow style for the connector
            connector2.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the condition shape with snooze shape using connector
            IConnector connector3 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 3, snoozeShape, 1);

            //Set the arrow style for the connector
            connector3.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the snooze shape with relay shape using connector
            IConnector connector4 = slide.Shapes.AddConnector(ConnectorType.Straight, snoozeShape, 0, relayShape, 2);

            //Set the arrow style for the connector
            connector4.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the relay shape with alarm shape using connector
            IConnector connector5 = slide.Shapes.AddConnector(ConnectorType.Straight, relayShape, 1, alarmShape, 3);

            //Set the arrow style for the connector
            connector5.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the condition shape with wake up shape using connector
            IConnector connector6 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 2, wakeUpShape, 0);

            //Set the arrow style for the connector
            connector6.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the wake up shape with end shape using connector
            IConnector connector7 = slide.Shapes.AddConnector(ConnectorType.Straight, wakeUpShape, 2, endShape, 0);

            //Set the arrow style for the connector
            connector7.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Add No textbox to slide
            IShape noTextBox = slide.Shapes.AddTextBox(564.02, 245.43, 51.32, 26.22);

            //Add a paragraph into the text box
            noTextBox.TextBody.AddParagraph("No");

            //Add Yes textbox to slide
            IShape yesTextBox = slide.Shapes.AddTextBox(487.21, 327.99, 50.09, 26.23);

            //Add a paragraph into the text box
            yesTextBox.TextBody.AddParagraph("Yes");

            MemoryStream ms = new MemoryStream();

            //Saves the presentation to the memory stream.
            presentation.Save(ms);
            //Set the position of the stream to beginning.
            ms.Position = 0;

            //Initialize the file stream to download the presentation.
            FileStreamResult fileStreamResult = new FileStreamResult(ms, "application/vnd.openxmlformats-officedocument.presentationml.presentation");

            //Set the file name.
            fileStreamResult.FileDownloadName = "Connector.pptx";

            return(fileStreamResult);
        }
コード例 #28
0
        /// <summary>
        /// Tracks the filtered object.
        /// </summary>
        /// <param name="theColorObject">The color object.</param>
        /// <param name="threshold">Threshold.</param>
        /// <param name="HSV">HS.</param>
        /// <param name="cameraFeed">Camera feed.</param>
        void trackFilteredObject(ColorObject theColorObject, Mat threshold, Mat HSV, Mat cameraFeed)
        {
            List <ColorObject> colorObjects = new List <ColorObject> ();
            Mat temp = new Mat();

            threshold.copyTo(temp);
            //these two vectors needed for output of findContours
            List <MatOfPoint> contours = new List <MatOfPoint> ();
            Mat hierarchy = new Mat();

            //find contours of filtered image using openCV findContours function
            Imgproc.findContours(temp, contours, hierarchy, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE);

            //use moments method to find our filtered object
            bool colorObjectFound = false;

            if (hierarchy.rows() > 0)
            {
                int numObjects = hierarchy.rows();

//						Debug.Log("hierarchy " + hierarchy.ToString());

                //if number of objects greater than MAX_NUM_OBJECTS we have a noisy filter
                if (numObjects < MAX_NUM_OBJECTS)
                {
                    for (int index = 0; index >= 0; index = (int)hierarchy.get(0, index)[0])
                    {
                        Moments moment = Imgproc.moments(contours [index]);
                        double  area   = moment.get_m00();

                        //if the area is less than 20 px by 20px then it is probably just noise
                        //if the area is the same as the 3/2 of the image size, probably just a bad filter
                        //we only want the object with the largest area so we safe a reference area each
                        //iteration and compare it to the area in the next iteration.
                        if (area > MIN_OBJECT_AREA)
                        {
                            ColorObject colorObject = new ColorObject();

                            colorObject.setXPos((int)(moment.get_m10() / area));
                            colorObject.setYPos((int)(moment.get_m01() / area));
                            colorObject.setType(theColorObject.getType());
                            colorObject.setColor(theColorObject.getColor());

                            colorObjects.Add(colorObject);

                            colorObjectFound = true;
                        }
                        else
                        {
                            colorObjectFound = false;
                        }
                    }
                    //let user know you found an object
                    if (colorObjectFound == true)
                    {
                        //draw object location on screen
                        drawObject(colorObjects, cameraFeed, temp, contours, hierarchy);
                    }
                }
                else
                {
                    Core.putText(cameraFeed, "TOO MUCH NOISE!", new Point(5, cameraFeed.rows() - 10), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Core.LINE_AA, false);
                }
            }
        }
コード例 #29
0
        private void btnCreatePresn_Click(object sender, EventArgs e)
        {
            //Create an instance for PowerPoint
            IPresentation presentation = Presentation.Create();

            //Add a blank slide to Presentation
            ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);

            //Add header shape
            IShape headerTextBox = slide.Shapes.AddTextBox(58.44, 53.85, 221.93, 81.20);
            //Add a paragraph into the text box
            IParagraph paragraph = headerTextBox.TextBody.AddParagraph("Flow chart with ");
            //Add a textPart
            ITextPart textPart = paragraph.AddTextPart("Connector");

            //Change the color of the font
            textPart.Font.Color = ColorObject.FromArgb(44, 115, 230);
            //Make the textpart bold
            textPart.Font.Bold = true;
            //Set the font size of the paragraph
            paragraph.Font.FontSize = 28;

            //Add start shape to slide
            IShape startShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 36.35, 133.93, 50.39);

            //Add a paragraph into the start shape text body
            AddParagraph(startShape, "Start", ColorObject.FromArgb(255, 149, 34));

            //Add alarm shape to slide
            IShape alarmShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 126.72, 133.93, 50.39);

            //Add a paragraph into the alarm shape text body
            AddParagraph(alarmShape, "Alarm Rings", ColorObject.FromArgb(255, 149, 34));

            //Add condition shape to slide
            IShape conditionShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDecision, 420.45, 222.42, 133.93, 97.77);

            //Add a paragraph into the condition shape text body
            AddParagraph(conditionShape, "Ready to Get Up ?", ColorObject.FromArgb(44, 115, 213));

            //Add wake up shape to slide
            IShape wakeUpShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 361.52, 133.93, 50.39);

            //Add a paragraph into the wake up shape text body
            AddParagraph(wakeUpShape, "Wake Up", ColorObject.FromArgb(44, 115, 213));

            //Add end shape to slide
            IShape endShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 453.27, 133.93, 50.39);

            //Add a paragraph into the end shape text body
            AddParagraph(endShape, "End", ColorObject.FromArgb(44, 115, 213));

            //Add snooze shape to slide
            IShape snoozeShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 624.85, 245.79, 159.76, 50.02);

            //Add a paragraph into the snooze shape text body
            AddParagraph(snoozeShape, "Hit Snooze button", ColorObject.FromArgb(255, 149, 34));

            //Add relay shape to slide
            IShape relayShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDelay, 624.85, 127.12, 159.76, 49.59);

            //Add a paragraph into the relay shape text body
            AddParagraph(relayShape, "Relay", ColorObject.FromArgb(255, 149, 34));

            //Connect the start shape with alarm shape using connector
            IConnector connector1 = slide.Shapes.AddConnector(ConnectorType.Straight, startShape, 2, alarmShape, 0);

            //Set the arrow style for the connector
            connector1.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the alarm shape with condition shape using connector
            IConnector connector2 = slide.Shapes.AddConnector(ConnectorType.Straight, alarmShape, 2, conditionShape, 0);

            //Set the arrow style for the connector
            connector2.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the condition shape with snooze shape using connector
            IConnector connector3 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 3, snoozeShape, 1);

            //Set the arrow style for the connector
            connector3.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the snooze shape with relay shape using connector
            IConnector connector4 = slide.Shapes.AddConnector(ConnectorType.Straight, snoozeShape, 0, relayShape, 2);

            //Set the arrow style for the connector
            connector4.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the relay shape with alarm shape using connector
            IConnector connector5 = slide.Shapes.AddConnector(ConnectorType.Straight, relayShape, 1, alarmShape, 3);

            //Set the arrow style for the connector
            connector5.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the condition shape with wake up shape using connector
            IConnector connector6 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 2, wakeUpShape, 0);

            //Set the arrow style for the connector
            connector6.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the wake up shape with end shape using connector
            IConnector connector7 = slide.Shapes.AddConnector(ConnectorType.Straight, wakeUpShape, 2, endShape, 0);

            //Set the arrow style for the connector
            connector7.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Add No textbox to slide
            IShape noTextBox = slide.Shapes.AddTextBox(564.02, 245.43, 51.32, 26.22);

            //Add a paragraph into the text box
            noTextBox.TextBody.AddParagraph("No");

            //Add Yes textbox to slide
            IShape yesTextBox = slide.Shapes.AddTextBox(487.21, 327.99, 50.09, 26.23);

            //Add a paragraph into the text box
            yesTextBox.TextBody.AddParagraph("Yes");

            //Saves the presentation
            presentation.Save("ConnectorSample.pptx");

            if (System.Windows.MessageBox.Show("Do you want to view the generated Presentation?", "Presentation Created",
                                               MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
#if !NETCore
                System.Diagnostics.Process.Start("ConnectorSample.pptx");
#else
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo("ConnectorSample.pptx")
                {
                    UseShellExecute = true
                };
                process.Start();
#endif
                this.Close();
            }
        }
コード例 #30
0
 public void unregisterTintable(ColorObject tintable)
 {
     tintables.Remove(tintable);
 }
コード例 #31
0
 public void registerTintable(ColorObject tintable)
 {
     tintables.Add(tintable);
 }
コード例 #32
0
                // Update is called once per frame
                void Update ()
                {
                        if (!initDone)
                                return;

                        if (screenOrientation != Screen.orientation) {
                                screenOrientation = Screen.orientation;
                                updateLayout ();
                        }

                        #if UNITY_IOS && !UNITY_EDITOR && (UNITY_4_6_3 || UNITY_4_6_4 || UNITY_5_0_0 || UNITY_5_0_1)
                        if (webCamTexture.width > 16 && webCamTexture.height > 16) {
                        #else
                        if (webCamTexture.didUpdateThisFrame) {
                                #endif

                                Utils.webCamTextureToMat (webCamTexture, rgbMat, colors);

                                if (webCamDevice.isFrontFacing) {
                                        if (webCamTexture.videoRotationAngle == 0) {
                                                Core.flip (rgbMat, rgbMat, 1);
                                        } else if (webCamTexture.videoRotationAngle == 90) {
                                                Core.flip (rgbMat, rgbMat, 0);
                                        }
                                        if (webCamTexture.videoRotationAngle == 180) {
                                                Core.flip (rgbMat, rgbMat, 0);
                                        } else if (webCamTexture.videoRotationAngle == 270) {
                                                Core.flip (rgbMat, rgbMat, 1);
                                        }
                                } else {
                                        if (webCamTexture.videoRotationAngle == 180) {
                                                Core.flip (rgbMat, rgbMat, -1);
                                        } else if (webCamTexture.videoRotationAngle == 270) {
                                                Core.flip (rgbMat, rgbMat, -1);
                                        }
                                }

                                //create some temp fruit objects so that
                                //we can use their member functions/information
                                ColorObject blue = new ColorObject ("blue");
                                ColorObject yellow = new ColorObject ("yellow");
                                ColorObject red = new ColorObject ("red");
                                ColorObject green = new ColorObject ("green");

                                //first find blue objects
                                Imgproc.cvtColor (rgbMat, hsvMat, Imgproc.COLOR_RGB2HSV);
                                Core.inRange (hsvMat, blue.getHSVmin (), blue.getHSVmax (), thresholdMat);
                                morphOps (thresholdMat);
                                trackFilteredObject (blue, thresholdMat, hsvMat, rgbMat);
                                //then yellows
                                Imgproc.cvtColor (rgbMat, hsvMat, Imgproc.COLOR_RGB2HSV);
                                Core.inRange (hsvMat, yellow.getHSVmin (), yellow.getHSVmax (), thresholdMat);
                                morphOps (thresholdMat);
                                trackFilteredObject (yellow, thresholdMat, hsvMat, rgbMat);
                                //then reds
                                Imgproc.cvtColor (rgbMat, hsvMat, Imgproc.COLOR_RGB2HSV);
                                Core.inRange (hsvMat, red.getHSVmin (), red.getHSVmax (), thresholdMat);
                                morphOps (thresholdMat);
                                trackFilteredObject (red, thresholdMat, hsvMat, rgbMat);
                                //then greens
                                Imgproc.cvtColor (rgbMat, hsvMat, Imgproc.COLOR_RGB2HSV);
                                Core.inRange (hsvMat, green.getHSVmin (), green.getHSVmax (), thresholdMat);
                                morphOps (thresholdMat);
                                trackFilteredObject (green, thresholdMat, hsvMat, rgbMat);

                                Utils.matToTexture2D (rgbMat, texture, colors);
                        }

                }

                void OnDisable ()
                {
                        webCamTexture.Stop ();
                }
コード例 #33
0
                /// <summary>
                /// Tracks the filtered object.
                /// </summary>
                /// <param name="theColorObject">The color object.</param>
                /// <param name="threshold">Threshold.</param>
                /// <param name="HSV">HS.</param>
                /// <param name="cameraFeed">Camera feed.</param>
                void trackFilteredObject (ColorObject theColorObject, Mat threshold, Mat HSV, Mat cameraFeed)
                {

                        List<ColorObject> colorObjects = new List<ColorObject> ();
                        Mat temp = new Mat ();
                        threshold.copyTo (temp);
                        //these two vectors needed for output of findContours
                        List<MatOfPoint> contours = new List<MatOfPoint> ();
                        Mat hierarchy = new Mat ();
                        //find contours of filtered image using openCV findContours function
                        Imgproc.findContours (temp, contours, hierarchy, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE);
                        //use moments method to find our filtered object
                        double refArea = 0;
                        bool colorObjectFound = false;
                        if (hierarchy.rows () > 0) {
                                int numObjects = hierarchy.rows ();

            //						Debug.Log("hierarchy " + hierarchy.ToString());

                                //if number of objects greater than MAX_NUM_OBJECTS we have a noisy filter
                                if (numObjects < MAX_NUM_OBJECTS) {
                                        for (int index = 0; index >= 0; index = (int)hierarchy.get(0, index)[0]) {

                                                Moments moment = Imgproc.moments (contours [index]);
                                                double area = moment.get_m00 ();

                                                //if the area is less than 20 px by 20px then it is probably just noise
                                                //if the area is the same as the 3/2 of the image size, probably just a bad filter
                                                //we only want the object with the largest area so we safe a reference area each
                                                //iteration and compare it to the area in the next iteration.
                                                if (area > MIN_OBJECT_AREA) {

                                                        ColorObject colorObject = new ColorObject ();

                                                        colorObject.setXPos ((int)(moment.get_m10 () / area));
                                                        colorObject.setYPos ((int)(moment.get_m01 () / area));
                                                        colorObject.setType (theColorObject.getType ());
                                                        colorObject.setColor (theColorObject.getColor ());

                                                        colorObjects.Add (colorObject);

                                                        colorObjectFound = true;

                                                } else {
                                                        colorObjectFound = false;
                                                }
                                        }
                                        //let user know you found an object
                                        if (colorObjectFound == true) {
                                                //draw object location on screen
                                                drawObject (colorObjects, cameraFeed, temp, contours, hierarchy);
                                        }

                                } else {
                                        Core.putText (cameraFeed, "TOO MUCH NOISE!", new Point (5, cameraFeed.rows () - 10), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar (255, 255, 255, 255), 2, Core.LINE_AA, false);
                                }
                        }
                }