Permalink
Browse files

adding track rotate method

  • Loading branch information...
1 parent 802f2f5 commit fc1be8af601bca45679d04c9a671a430cefb5ffe @ryanb committed Jul 13, 2009
Showing with 21 additions and 0 deletions.
  1. +15 −0 ext/track.c
  2. +6 −0 spec/quicktime/track_spec.rb
View
15 ext/track.c
@@ -279,6 +279,20 @@ static VALUE track_translate(VALUE obj, VALUE x, VALUE y)
}
/*
+ 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: bounds() -> bounds_hash
Returns a hash of boundaries. The hash contains four keys: :left, :top,
@@ -339,6 +353,7 @@ void Init_quicktime_track()
rb_define_method(cTrack, "enable_alpha", track_enable_alpha, 0);
rb_define_method(cTrack, "scale", track_scale, 2);
rb_define_method(cTrack, "translate", track_translate, 2);
+ rb_define_method(cTrack, "rotate", track_rotate, 1);
rb_define_method(cTrack, "bounds", track_bounds, 0);
rb_define_method(cTrack, "reset_transformations", track_reset_transformations, 0);
}
View
6 spec/quicktime/track_spec.rb
@@ -71,6 +71,12 @@
@track.bounds[:right].should == 60
@track.bounds[:bottom].should == 50
end
+
+ it "should rotate track" do
+ @track.rotate(90)
+ @track.width.should == 50
+ @track.height.should == 60
+ end
end
describe "audio track" do

0 comments on commit fc1be8a

Please sign in to comment.