greenhouse
a creative coding toolkit for spatial interfaces

Color

An RGBA color value (A is known as alpha or transparency).

  • Color ()
  • HSB ()

Example

#include "Greenhouse.h"

void SlapSampleOnFeld (int64 row, int64 col)
{ float64 wid = Feld () -> Width () / 3;
  float64 hei = Feld () -> Height () / 3;
   Vect start = Feld () -> Loc () - 0.5 * (Feld () -> Width () - wid) * Feld () -> Over ()
     - 0.5 * Feld () -> Height () * Feld () -> Up ();

  int64 i = row * 3 + col;
  INFORM (ToStr(i));

  Image *img = new Image ("images/pill2.png");
  img -> SlapOnFeld ();
  img -> SetAlignment (-1.0, 0.0);
  img -> SetHeightUniformly (0.6*hei);
  Vect t = start +
           col * wid * Feld () -> Over () +
           row * hei * Feld () -> Up ();
  img -> SetTranslation (t);

  Image *rct = new Image ();
  rct -> SlapOnFeld ();
  rct -> SetWidth (wid);
  rct -> SetHeight (hei);
  rct -> SetAlignment (-0.5, 0.0);
  rct -> SetTranslation (t);

  Text *txt = new Text ("pill");
  txt -> SlapOnFeld ();
  txt -> SetFontSize (0.14 * hei);
  txt -> SetAlignment (-0.8, 0.0);
  txt -> SetTranslation (t);

  if (i == 0)
    { txt -> SetString ("Color ()");
      txt -> SetTextColor (Color (0.0, 1.0));
      rct -> SetAdjColor (Color ());
    }
  else if (i == 1)
    { txt -> SetString ("Color (0.5)");
      rct -> SetAdjColor (Color (0.5));
    }
  else if (i == 2)
    { txt -> SetString ("Color (1.0, 0.5)");
      rct -> SetAdjColor (Color (1.0, 0.5));
    }
  else if (i == 3)
    { txt -> SetString ("Color (1.0, 0.0, 0.0)");
      rct -> SetAdjColor (Color (1.0, 0.0, 0.0));
    }
  else if (i == 4)
    { txt -> SetString ("Color (1.0, 0.0, 0.0, 0.5)");
      rct -> SetAdjColor (Color (1.0, 0.0, 0.0, 0.5));
    }
  else if (i == 5)
    { txt -> SetString ("RGB (0.0, 1.0, 0.0)");
      txt -> SetTextColor (Color (0.0, 1.0));
      rct -> SetAdjColor (Color (0.0, 1.0, 0.0));
    }
  else if (i == 6)
    { txt -> SetString ("RGB (0.0, 1.0, 0.0, 0.5)");
      rct -> SetAdjColor (Color (0.0, 1.0, 0.0, 0.5));
    }
  else if (i == 7)
    { txt -> SetString ("HSB (0.5, 0.5, 0.5)");
      txt -> SetTextColor (Color (0.0, 1.0));
      rct -> SetAdjColor (HSB (0.5, 0.5, 0.5));
    }
  else if (i == 8)
    { txt -> SetString ("HSB (0.5, 0.5, 0.5, 0.5)");
      rct -> SetAdjColor (HSB (0.5, 0.5, 0.5, 0.5));
    }
  else
    rct -> SetAdjColor (Color (1.0, 0.0));
}


void Setup ()
{ for (int64 row = 0  ;  row < 3  ;  row++)
    for (int64 col= 0  ;  col < 3  ;  col++)
      SlapSampleOnFeld (row, col);
}