iphone - CGContext rotation -


I have a 100x100 pixel image that I want to draw on different angles rotated around the center of the image. The following code works, but moves around the original origin of the coordinate system (upper left hand corner) and is not a translated place. Thus, the image is rotated in the upper left corner of the screen, not around it.

The following code was played with someone else in a blank application, but nothing else.

  - (zero) direct: (CGRTact) rect {CGContextRef context = UIGraphicsGetCurrentContext (); CGContextTranslateCTM (Reference, -50, -50); CGContextRotateCTM (reference, 0.3); CGContextTranslateCTM (references, 768 / 2,1024 / 2); [Image dotpointpoint: CGPindMake (0,0)]; }  

I tried to do this using Cagefin Transformers, but I got the same result.

Rotation is always about the origin; What you need to do is not to defeat it, but rather to take advantage of it.

The key to remember here is that the translation transfers the original, so, if you want to center the screen in center center and want to rotate the image around that center, What you need to do:

  1. Move the original to the center of the screen.
  2. Rotate by the desired amount (imagine x axis keeps moving, the left edge goes down, and dispersed at the right end.)
  3. The original "left" and The "bottom" is happening with the new X and Y axes being half-size of the image.

Imagine the speed of the image on the iPad through each of these steps. Or, better yet take a post-it note and simulate it by hand:

  1. Get started with a note in one corner of the iPad.
  2. Note that the note is in the corner of the note in the center of the iPad.
  3. Rotate notes around that corner.
  4. Note that "left" and "down" (relative of themselves) from their height

You will note that the notes are rotated and will end in the center.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -