GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


ImageTransformation by burly
private void DrawNeedle(Graphics g, float angle)
        {
            Metafile myMetafile = new Metafile("needle.emf");
            float dx, dy, x, y;
           
            // Calculate the offsets
            dx = (float)Radius * (float)Math.Sin(DegreesToRadians(angle));
            dy = (float)Radius * (float)Math.Cos(DegreesToRadians(angle));
            
            // Determine the new drawing point
            x = Center.X + dx;
            y = Center.Y - dy;
            
            // Draw the unrotated image
            g.DrawImage(myMetafile, x, y, 10, Radius);
            
            // Rotate and draw the new image
            g.RotateTransform(angle);
            g.DrawImage(myMetafile, x, y, 10, Radius);
           
            // These are the points that actually look correct when rotated
            // g.DrawImage(myMetafile, 83, 45, 10, Radius);    
        }