greenhouse
a creative coding toolkit for spatial interfaces

Scaling methods for Node objects

Scaling an object in absolute space (always in millimeters).

For more explanation of the Greenhouse coordinate system and how translation, rotation, and scaling is managed, see this article in the section on wrangling.

About animation Various kinds of animation can be applied to how objects scale. First, we set up what kind of animation we would like (linear, quadratic, etc.), and second, we set some endpoint (or goal) to animate towards – typically with a call to, say, SetScale().

It’s worth noting that if you plan to update the goal of an animation frequently while the animation is still happening, you may not always get the behavior you expect. Currently, most of the animation functions reset their internal animation timer back to its starting point when SetScale() is called.

The only flavor of animation that’s appropriate for continuously updating the goal is “Chase”. This may be a direction for future API improvement.

  • SetScale ()
  • SetScaleHard ()
  • IncScale ()
  • Scale ()
  • CumulativeScale ()
  • ScaleGoal ()
  • ScaleIsStatic ()
  • ScaleAnimateChase ()
  • ScaleAnimateLinear ()
  • ScaleAnimateQuadratic ()
  • ScaleAnimateAsymp ()
  • ScaleAnimateSine ()

Example

#include "Greenhouse.h"

class Watermark  :  public Image //subclassing from Image
{ public:
  Text *label;

  Watermark (const Str &img)  :  Image (img) // constructor
  { label = new Text ("greenhouse");
    label -> SetScale (0.8);
    AppendKid (label);
  }

  void Travail ()
  { if (! ScaleIsStatic ())
      INFORM ("Scale () = " + ToStr (Scale ()) +
              ", desired_scale = " + ToStr (ScaleGoal ()) +
              "\nLabel: relative_scale = " + ToStr (label -> Scale ()) +
              ", total_scale = " + ToStr (label -> CumulativeScale ()));
  }

  void Blurt (BlurtEvent *e)
  { if (Utters (e, "+"))
      IncScale (0.1);
    if (Utters (e, "-"))
      IncScale (-0.1);
    if (Utters (e, "f"))
      SetScaleHard (1.8);
  }

  void PointingHarden (PointingEvent *e)
  { if (ScaleGoal () == 1.2)
      SetScale (1.0);
    else
      SetScale (1.2);
  }
};

void Setup ()
{ Watermark *backing = new Watermark ("images/gh-application-icon.png");
  backing -> SetAdjColor(Color (0.6, 0.8));
  backing -> SetScale (1.2);
  backing -> SlapOnFeld ();

  backing -> ScaleAnimateChase (1.2); //seconds
  //backing -> ScaleAnimateLinear (1.2); //seconds
  //backing -> ScaleAnimateQuadratic (1.2); //seconds
  //backing -> ScaleAnimateAsymp (1.2); //seconds
  // amount, frequency, and phase
  //backing -> ScaleAnimateSine (Vect (0.3, 0.1, 0), 0.5, 0);
}