/* call-seq: reset_transformations() Revert any transformations (scale, translate, rotate) performed on this track. */ static VALUE track_reset_transformations(VALUE obj) { MatrixRecord matrix; GetTrackMatrix(TRACK(obj), &matrix); SetIdentityMatrix(&matrix); SetTrackMatrix(TRACK(obj), &matrix); return obj; }
/* call-seq: translate(x, y) Offset a track's position by x and y values respectively. Values should be in pixels. */ static VALUE track_translate(VALUE obj, VALUE x, VALUE y) { MatrixRecord matrix; GetTrackMatrix(TRACK(obj), &matrix); TranslateMatrix(&matrix, FloatToFixed(NUM2DBL(x)), FloatToFixed(NUM2DBL(y))); SetTrackMatrix(TRACK(obj), &matrix); return obj; }
/* call-seq: rotate(degrees) Rotate the track by the given number of degrees. */ static VALUE track_rotate(VALUE obj, VALUE degrees) { MatrixRecord matrix; GetTrackMatrix(TRACK(obj), &matrix); RotateMatrix(&matrix, FloatToFixed(NUM2DBL(degrees)), 0, 0); SetTrackMatrix(TRACK(obj), &matrix); return obj; }
/* call-seq: scale(width, height) Scale the track's size by width and height respectively. The value passed is a relative float where "1" is the current size. */ static VALUE track_scale(VALUE obj, VALUE width, VALUE height) { MatrixRecord matrix; GetTrackMatrix(TRACK(obj), &matrix); ScaleMatrix(&matrix, FloatToFixed(NUM2DBL(width)), FloatToFixed(NUM2DBL(height)), 0, 0); SetTrackMatrix(TRACK(obj), &matrix); return obj; }
OSErr QTTarg_AddTextToggleButtonTrack (Movie theMovie) { Track myTrack = NULL; Media myMedia = NULL; MatrixRecord myMatrix; RGBColor myKeyColor; Fixed myWidth, myHeight; TimeValue myDuration = 0L; TimeValue myTimeScale = 0L; OSErr myErr = noErr; ////////// // // get some information about the target movie // ////////// if (theMovie == NULL) { myErr = paramErr; goto bail; } myWidth = Long2Fix(2 * kButtonWidth); myHeight = Long2Fix(2 * kButtonHeight); myDuration = GetMovieDuration(theMovie); myTimeScale = GetMovieTimeScale(theMovie); ////////// // // create a new sprite track in the target movie // ////////// myTrack = NewMovieTrack(theMovie, myWidth, myHeight, kNoVolume); myMedia = NewTrackMedia(myTrack, SpriteMediaType, myTimeScale, NULL, 0); // set the track matrix to compensate for any existing movie matrix GetMovieMatrix(theMovie, &myMatrix); if (InverseMatrix(&myMatrix, &myMatrix)) SetTrackMatrix(myTrack, &myMatrix); myErr = BeginMediaEdits(myMedia); if (myErr != noErr) goto bail; ////////// // // add sprite images and sprites to the sprite track; add actions to the sprites // ////////// QTTarg_AddTextButtonSamplesToMedia(myMedia, 2 * kButtonWidth, 2 * kButtonHeight, myDuration); ////////// // // insert media into track // ////////// myErr = EndMediaEdits(myMedia); if (myErr != noErr) goto bail; // add the media to the track InsertMediaIntoTrack(myTrack, 0, 0, GetMediaDuration(myMedia), fixed1); ////////// // // set the sprite track properties // ////////// QTTarg_SetTrackProperties(myMedia, kNoQTIdleEvents); // no idle events myKeyColor.red = myKeyColor.green = myKeyColor.blue = 0xffff; // white MediaSetGraphicsMode(GetMediaHandler(myMedia), transparent, &myKeyColor); // make sure that the sprite track is in the frontmost layer SetTrackLayer(myTrack, kMaxLayerNumber); SetTrackLayer(myTrack, QTTarg_GetLowestLayerInMovie(theMovie) - 1); bail: return(myErr); }