Advanced Search

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Rotate an Image 90° or 180° ?

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,641
    Thanks
    42
    Thanked 2,897 Times in 2,869 Posts
    Blog Entries
    12

    Default

    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #12
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,484
    Thanks
    4
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Currently I am looking from scratch. I am thinking I can do some simple math here. maybe a bit of sin() and rounding to grab the current top/left x/y on click and on release use the math to change the bottom/right x/y co-ord to the new co-ords top/left. In essence this would just move the image up and over, but if I also set new x/y for the top/left to be bottom/right (swapping the co-ords in a sence) the image should "rotate"...

    still working on the math at the moment though
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #13
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    You can use coordinate system transformation techniques for this I think.
    If you calculate each pixel's distance from a defined origin (the simplest is sqrt(x^2 + y^2)), and get the angle of the line joining the pixel and the origin (the simplest would be arctan(y/x), and then add the rotation angle to this calculated angle and recalculate the new x&y coordinates by simply multiplying the distance of the pixel with sin(teta) for y and cos(teta) for x axis(where teta stands for the new angle we have just calculated), it should be done. Without any anti-aliasing and etc. of course

    Edit: I found a library at http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm for purposes like these and also I have learnt a "canvas" tag for FF, digging it
    Last edited by BYK; 12-16-2007 at 10:11 PM.

  4. #14
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,641
    Thanks
    42
    Thanked 2,897 Times in 2,869 Posts
    Blog Entries
    12

    Default

    Zorn himself doesn't recommend using his method for rotating images.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #15
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    May be it can be possible this canvas tag. The "image reflection" script seems good and now I'm examining it.

    It uses IE's filters for the reflection effect but the canvas tag for Fx and others.
    Last edited by BYK; 12-18-2007 at 10:48 AM.

  6. #16
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,484
    Thanks
    4
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    well, the obvious answer is multiple images loaded onClick... but where is the fun in that?
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #17
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,641
    Thanks
    42
    Thanked 2,897 Times in 2,869 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by BLiZZaRD View Post
    well, the obvious answer is multiple images loaded onClick... but where is the fun in that?
    That's one of the first things I mentioned. That could be impractical if there are many images that need this treatment.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #18
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,484
    Thanks
    4
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Yes I noted that suggestion of yours, which spawned my interest in finding a way to do this. I am thinking. It is a fun little distraction project for me while I am here at work
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #19
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,641
    Thanks
    42
    Thanked 2,897 Times in 2,869 Posts
    Blog Entries
    12

    Default

    I got a Beta version working:

    http://home.comcast.net/~jscheuer1/side/flip.htm

    Opera appears to soften the image as well as flip it, FF seems to shift its vertical by 1px, cutting off a 1px piece when flipped. IE 7 and Safari 3 Win seem 'perfect'. IE 5.5 might have problems or throw an error.

    Usage is simple:

    onclick="flip(this);"

    A unique id is required, and if you want to style the image, use the stylesheet so that the styles will carry over in non-IE browsers.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #20
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    Seems good&working but unfortunately we cannot rotate to an arbitrary angle.
    By the way were you aware of the "canvas" tag before? I saw it in that reflection script for the first time since I'm developing JS&DHTML codes for some time.

Bookmarks

Posting Permissions

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