A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: BitmapData getPixel on rotating movieClip?

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930

    BitmapData getPixel on rotating movieClip?

    This may be more of a math question as I try variations on this problem. I'm trying to get the rgb value from a pixel area on the stage that a bitmap is rotating in. I made it work for the y by adjusting the getPixel location in the bitmap, but I think I need to use some sin/cos to "rotate" the x/y location for the getRGB...

    am I making this harder than it needs to be?

    any ideas?? fla attached...

    Thanks!
    Last edited by flashpipe1; 12-10-2008 at 02:15 PM.
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    Viral tick lordofduct's Avatar
    Join Date
    May 2008
    Location
    South Florida
    Posts
    159
    so the respect of the point you are checking is in respect to outside of the circle_mc which is rotated and you are comparing against just the BitmapData.

    All you've go to do is transform the position to inside of the circle. Yeah it'd take some sin and cos, or you can use matrices, OR you could use the Flash defined method for doing it.

    like so:

    circle_mc.globalToLocal( new Point( stagePositionX, stagePositionY ) );

    then check those values... remember bitmaps are whole pixels, integers only work. So either floor or round for the effect you want.

    sin and cos would be your answer as well. But it's a lot more work then you need. And depends upon the point in which the circle_mc rotates, I'm assuming the center so you'd basically just take the distance from the point checking to the center of the circle. then multiply those by sin and cosine of the angle of rotation:

    Code:
    var d:Number = //distance between global point to check and global point of the circle's center
    var ix:Number = Math.cos(circle_mc.rotation * Math.PI / 180); //convert to radians
    ix *= d;
    var iy:Number = Math.sin(circle_mc.rotation * Math.PI / 180);
    iy *= d;
    the matrix method is just a lot of processing work in comparison, so don't even both with it. But you basically just transform the matrix of one point by the other and pop out the resulting point. Due to Flash's ****ty Matrix Class that offers no real matrix math accept for "concat" it is highly inefficient and clumsy.
    Last edited by lordofduct; 08-23-2008 at 02:23 AM.

  3. #3
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    Got it...In case anyone else needs to do something like this, I used the following equations to set the adjustX and adjustY.

    angle = the _x of the rot slider
    rad = the _x of the y slider

    adjustX=cx+Math.sin(angle)*rad;
    adjustY=cy+Math.sin(angle)*rad;

    Works GREAT!!

    Thanks!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center