benkuper / Chataigne

Artist-friendly Modular Machine for Art and Technology
https://benjamin.kuperberg.fr/chataigne
GNU General Public License v3.0
1.19k stars 56 forks source link

Color type improvements #87

Open EmerickH opened 3 years ago

EmerickH commented 3 years ago

To be able to control LED strips and DMX fixtures, it would be really nice to have the possibility to have:

I know it's actually possible to achieve that without using the Color variable type, but in the timeline view, being able to visualize your color gradient is very cool, and using 1 line for each color takes a lot of space.

Possible solutions I've though of: It could be solved by:

Changes that are necessary

Who's gonna do that? @benkuper I do have the intention to work on that myself, but I just wanted to know if you had others ideas and/or a preferred way to implement that. I hope my ideas are clear enough, if you want more precision I can try to make conceptual screenshots to show you how I think things could be implemented.

EmerickH commented 3 years ago

Firsts ideas for creating a new customizable color class: (pseudo-code, not functional of course)

enum ColorDisplay
{
  R,
  G,
  B,
  W,
  WW,
  A, // Controls opacity
  MASTER, // Controls luminosity
  NONE // Not shown in preview
}

class AdvancedColorParameter
{
  float value;
  String name; // Name to show in the GUI
  ColorDisplay previewAs; // How this color is displayed in preview
}

class AdvancedColor
{
  List<AdvancedColorParameter> parameters; // List of all color components

  Juce::Color getPreviewColor() // Returns a color to show in the GUI (boxes, timelines,...)
  {
    float R = 0;
    float G = 0;
    float B = 0;
    float Alpha = 1.0;
    float master = 1.0;
    foreach(parameter in parameters)
    {
      switch(parameter->previewAs)
      {
         case ColorDisplay::R:
           R = parameter->value;
           break;
         (....)
         case ColorDisplay::W:
           R+= parameter->value; // Probably not the way to do that but you get the idea
           G+= parameter->value;
           B+= parameter->value;
        (...)
    }
    return new Juce::Color(R*master,G*master,B*master,Alpha);
  }

  float[] getColor() // Returns the true color with all components in an array
  {
    // Create a float array with the values of parameters elements
  }

  void setPreconfig(ColorPreconfig preconf){
    parameters.Clear();
    switch(preconf){
      case RGB;
        parameters.Add(new AdvancedColorParameter(0.0, "R", ColorDisplay::R);
        parameters.Add(new AdvancedColorParameter(0.0, "G", ColorDisplay::G);
        parameters.Add(new AdvancedColorParameter(0.0, "B", ColorDisplay::B);
        break;
     (...)
  }
}

enum ColorPreconfig
{
  RGB,
  RGBW,
  RGBWW,
  RGBA
...
}

BUT this way to create a dynamic customizable object causes a lot of problem while storing this in variables for example: what list of parameters to expect in the variable? Overriding it every time we store a value? But how to edit manually the variable?...

The other way to go could be the "hard way" by putting just every possible color and using only the one we need but that means more useless processing and less customization:

class AdvancedColor
{
  float R,G,B,W,WW,A,Alpha,Master;
}
benkuper commented 3 years ago

This seems very interesting, although for me it is already pushing Chataigne towards dedicated DMX/Light show creation, which is not its first aim. Going this direction would mean also integrating VST support for audio, Image analysis, etc. which is exactly what Chataigne is NOT about. But color formats can be interesting in other manners I reckon. I would still take some time to consider what this actually means and why do that (and how !)

Thanks for the input and work, it's a very good base to discuss upon :)