RectHit, Or Bill Atkinson is an awesome dude -QuickDraw and QC collide....

The release of the original source code for MacPaint is something that sent the world of computer geeks into a tizzy this past week.

This led me to do some reading about Bill Atkinson. In an interview (sorry, can't find the link) he described a technique that uses two points for a hit test. He described how by keeping track of coordinates of the bottom right corner and the top left corner of a sprite, how a hit test can be made. I found that to be conceptually interesting, so I decided to remake the setup in QC.

By knowing the width and height of the sprite, one can determine the corner points, and then test if a cursor is inside or outside of them using conditionals, and then finally use logic on both conditionals to determine the hit.

This led me to make a little demo where simply hovering over the specified hit area triggers a sprite on. That, to me, is very interesting, because it is a method of making QC externally driven, in essence.

However, for the uploaded demo, I have the RectHit hit test controlling the color of the sprite, and a counter to show the current hit count. I've done this because actually seeing the Sprite when the composition opens is likely to be less confusing, and the visualization of the hit still occurs via color change and counter, though I find the concept of turning on a render patch via external interaction to be more novel. It also shows how hitting a given coordinate can trigger something "on". With some further patching, a button that responds to coordinate position and mouse down can be made.

The RectHit patch outputs should be hooked to the corresponding inputs of the Sprite to work properly, as shown in the RectHit demo.

This patch won't work correctly if one puts it inside of a 3D transform and offsets it, unless some extra math occurs with the @X and @Y inputs to account for any X/Y translations that may occur inside of 3D transforms that the RectHit is nested in. As is, it only accounts for X/Y translation of the Sprite itself; this is why X/Y translation and width and height need to be entered into the RectHit patch, and then hooked to the Sprite.

I uploaded the patch @ : http://kineme.net/composition/gtoledo3/RectHit