greenhouse
a creative coding toolkit for spatial interfaces

Pointing Events

Pointing Events from input devices such as the Hantenna pipeline, iOS app, or mouse.

  • PointingAppear ()
  • PointingVanish ()
  • PointingMove ()
  • PointingMoveEnter ()
  • PointingMoveExit ()
  • PointingInsideMove ()
  • PointingOutsideMove ()
  • PointingHarden ()
  • PointingInsideHarden ()
  • PointingOutsideHarden ()
  • PointingSoften ()
  • PointingInsideSoften ()
  • PointingOutsideSoften ()
  • IsHardened ()

Example

#include "Greenhouse.h"
#include "Label.h"

class CustomText  :  public Text
{ public:
  CustomText (const Str &s)  :  Text (s)   { SetAlpha (0.5); }

  void PointingAppear (PointingEvent *e)
    { INFORM (e -> Provenance () + " just made a PointingAppear ()"); }

  void PointingVanish (PointingEvent *e)
    { INFORM (e -> Provenance () + " just made a PointingVanish ()"); }

  void PointingHarden (PointingEvent *e)
    { INFORM (e -> Provenance () + " just made a PointingHarden ()"); }

  void PointingInsideHarden (PointingEvent *e)
    { if (IsHeedless ())
        Heed (e);
    }

  void PointingOutsideHarden (PointingEvent *e)
    { INFORM (e -> Provenance () + " just made a PointingOutsideHarden ()"); }

  void PointingMove (PointingEvent *e)
    { if (IsHeeding (e))  //  drag the object
        IncTranslation (IntersectionDiff (e, Loc ()));
    }

  void PointingMoveEnter (PointingEvent *e)
    { SetAlpha (1.0);
      Heartbeat ();
    }

  void PointingMoveExit (PointingEvent *e)
    { SetAlpha (0.5); }

  void PointingInsideMove (PointingEvent *e)
    { if (IsHeedless () && IsHardened (e))
        Heed (e);
      float dist = (Intersection (e) - Loc ()) . Dot (Over ());
      dist = 2.0 * dist / Width ();
      Color c = dist > 0 ? Color (dist, 1 - dist, 0, 1) : Color (0, 1 + dist, -dist, 1);
      SetAdjColor (c);
    }

  void PointingOutsideMove (PointingEvent *e)
    { Vect up = (Loc () - Intersection (e)) . Norm ();
      SetRotation (Norm (), - up . Cross (Norm ()));
    }

  void PointingSoften (PointingEvent *e)
    { if (IsHeeding (e))
        StopHeeding ();
    }

  void PointingInsideSoften (PointingEvent *e)
    { INFORM (e -> Provenance () + " just made a PointingInsideSoften ()"); }

  void PointingOutsideSoften (PointingEvent *e)
    { INFORM (e -> Provenance () + " just made a PointingOutsideSoften ()"); }

};

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