greenhouse
a creative coding toolkit for spatial interfaces

Softs

An easing function that can be applied to translation, rotation, scale and/or color.

  • TranslationAnimateLinear ()
  • TranslationAnimateQuadratic ()
  • TranslationAnimateAsymp ()
  • TranslationAnimateChase ()
  • TranslationAnimateSine ()
  • TranslationAnimateOrbit ()
  • ScaleAnimateLinear ()
  • ScaleAnimateQuadratic ()
  • ScaleAnimateAsymp ()
  • ScaleAnimateChase ()
  • ScaleAnimateSine ()
  • RotationAnimateLinear ()
  • RotationAnimateQuadratic ()
  • RotationAnimateAsymp ()
  • RotationAnimateChase ()
  • RotationAnimateSine ()
  • ColorAnimateLinear ()
  • ColorAnimateQuadratic ()
  • ColorAnimateAsymp ()
  • ColorAnimateSine ()
  • TranslationIsStatic ()
  • ScaleIsStatic ()
  • RotationIsStatic ()
  • AdjColorIsStatic ()

Example

//Create a CustomText () class and install a variety of softs

#include "Greenhouse.h"

class CustomText  :  public Text
{
  public:

  CustomText (const Str &s)  :  Text (s)
    { }

  void Travail ()
    { if (!TranslationIsStatic ())
        INFORM ("Translation = " + ToStr (Translation ()));
      if (!ScaleIsStatic ())
        INFORM ("Scale = " + ToStr (Scale ()));
      if (!RotationIsStatic ())
        INFORM ("Rotation = " + ToStr (Angle ()));
      if (!AdjColorIsStatic ())
        INFORM ("AdjColor = " + ToStr (AdjColor ()));
    }

  void PointingHarden (PointingEvent *e)
    { SetTranslation (Intersection (e, Feld () -> Loc ()));
      SetScale (Random (.2, 2));
      SetRotation (Vect (0, 0, 1), Random (0, 2 * PI));
      SetAdjColor (Color (Random(1), Random(1), Random(1)));
    }
};

void Setup ()
{ CustomText *ct = new CustomText ("Hello, softs!");
  ct -> SlapOnFeld ();

  ct -> TranslationAnimateQuadratic (1); //seconds
  //ct -> TranslationAnimateLinear (1); //seconds
  //ct -> TranslationAnimateAsymp (1); //seconds
  //ct -> TranslationAnimateChase (1); //seconds
  // amount, frequency, and phase
  //ct -> TranslationAnimateSine (Vect (100, 90, 0), 1, 0);
  // major_axis, minor_axis, and frequency
  //ct -> TranslationAnimateOrbit (Vect (100, 0, 0), Vect (0, 90, 0), 1);
  ct -> SetTranslationHard (Vect (Inside (Feld (), Vect (Random(0,.5), Random(0,.5), 0))));

  ct -> ScaleAnimateQuadratic (2); //seconds
  //ct -> ScaleAnimateLinear (2); //seconds
  //ct -> ScaleAnimateAsymp (2); //seconds
  //ct -> ScaleAnimateChase (2); //seconds
  // amount, frequency, and phase
  //ct -> ScaleAnimateSine (Vect (0.3, 0.1, 0), 0.5, 0);
  ct -> SetScaleHard (Random (.2, 1));

  ct -> RotationAnimateQuadratic (1.5); //seconds
  //ct -> RotationAnimateLinear (1.5); //seconds
  //ct -> RotationAnimateAsymp (1.5); //seconds
  //ct -> RotationAnimateChase (1.5); //seconds
  // axis, angle, frequency, and phase
  //ct -> RotationAnimateSine (Vect (0, 0, 1), M_PI / 2, 1, 0);
  ct -> SetRotationHard (Vect (0, 0, 1), Random (0, 2 * PI));

  ct -> ColorAnimateQuadratic (3); //seconds
  //ct -> ColorAnimateLinear (3); //seconds
  //ct -> ColorAnimateAsymp (3); //seconds
  // amount, frequency, and phase
  //ct -> ColorAnimateSine (Color (0.5), 1, 0);
  ct -> SetAdjColorHard (Color (Random(0,1), Random(0,1), Random(0,1)));
}