Random RGB effect

Schlagwörter: 

Ansicht von 1 Antwort-Thema
  • Autor
    Beiträge
    • #247162
      Robbert Mak
      Teilnehmer

      Hi,

      where can I find a truly random rgb effect?

      Thanks again.

      Robbert

    • #247167
      Christoph PaduchChristoph Paduch
      Moderator

      Hello Robbert, the particle and noise effects are random. That has also disadvantages, because you cannot loop them in an easy way.
      Or do you only want to create a random color or random color changes?
      Then you can use scripting for creating the next color and set the color in the effect.

      Here an example to create a random number:

      using System;
      using Scripting;

      public static class RandomNumber
      {
      private static Random rnd = new Random();

      // returns a Random number including the min and max value
      public static int Run(int min, int max)
      {
      return rnd.Next(min, max+1);
      }
      }

      And an example to create a color from the color temperature in range 0..360°:

      using System;
      using Scripting;
      using Ecue.Base.Data.Rendering;

      /// <summary>
      /// Example without warranty.
      /// Takes a ColorTemperature in the range 0..360° like the colors in the Color Picker Wheel and calculates the RGB parts and a corresponding ProPhotoColor.
      /// </summary>
      public static class ColorConvert
      {
      public static void Run(double colorTemperature, out int red, out int green, out int blue, out ProPhotoColor color)
      {
      red = 0;
      blue = 0;
      green = 0;

      //calculate blue
      if (colorTemperature >= 90 && colorTemperature <= 210)
      {
      blue = 255;
      }
      else if (colorTemperature < 90 && colorTemperature > 30)
      {
      blue = (int)( Math.Abs(colorTemperature - 30.0)*4.25);
      }
      else if (colorTemperature > 210 && colorTemperature < 270)
      {
      blue = (int)( Math.Abs(colorTemperature - 270.0)*4.25);
      }

      //calculate green
      if (colorTemperature <= 90 || colorTemperature >= 330)
      {
      green = 255;
      }
      else if (colorTemperature < 150)
      {
      green = (int)( Math.Abs(colorTemperature - 150.0)*4.25);
      }
      else if (colorTemperature > 270)
      {
      green = (int)( Math.Abs(colorTemperature -270.0)*4.25);
      }

      //calculate red
      if (colorTemperature <= 330 && colorTemperature >= 210)
      {
      red = 255;
      }
      else if (colorTemperature > 150 && colorTemperature < 210)
      {
      red = (int)(Math.Abs(colorTemperature - 150.0)*4.25);
      }
      else if (colorTemperature < 30 )
      {
      red = (int)( Math.Abs(colorTemperature - 30.0)*4.25);
      }
      else if (colorTemperature > 330 )
      {
      red = (int)( Math.Abs(colorTemperature - 390.0)*4.25);
      }

      color = new ProPhotoColor((float)(red / 255.0), (float)(green/ 255.0), (float)(blue/ 255.0), 1f);
      }
      }

      I hope this helps to realize your ideas.


      Freundliche Grüße / Kind regards
      Christoph

Ansicht von 1 Antwort-Thema
  • Du musst angemeldet sein, um auf dieses Thema antworten zu können.