Rotate Text

Posts 115 of 16 · Page 1 of 2
Rotate Text
Well i thought it would be a good idea to have rotated text in a menu. Does anyone know how to do it?Is their a known functions?


/Discuss
Lol what a coincidence I was just needing that too...
Apparently you need to use SetTransform
[Answer] Rotate text

@NOOBJr, @Crash
I just started C++ so check this before anyone Copy's.
First, create a CFont with the angle of rotation specified in nEscapement. Let your DC select this font and call the following function:
Code:
#include <cmath>

// pDC : pointer to your device-context

// str : the text

// rect: the rectangle

// nOptions: can be a combination of ETO_CLIPPED and ETO_OPAQUE

void DrawRotatedText(CDC* pDC, const CString str, CRect rect, 
                     double angle, UINT nOptions = 0)
{
   // convert angle to radian

   double pi = 3.141592654;
   double radian = pi * 2 / 360 * angle;
 
   // get the center of a not-rotated text

   CSize TextSize = pDC->GetTextExtent(str);
   CPoint center;
   center.x = TextSize.cx / 2;
   center.y = TextSize.cy / 2;
 
   // now calculate the center of the rotated text

   CPoint rcenter;
   rcenter.x = long(cos(radian) * center.x - sin(radian) * center.y);
   rcenter.y = long(sin(radian) * center.x + cos(radian) * center.y);
 
   // finally draw the text and move it to the center of the rectangle

   pDC->SetTextAlign(TA_BASELINE);
   pDC->SetBkMode(TRANSPARENT);
   pDC->ExtTextOut(rect.left + rect.Width() / 2 - rcenter.x, 
                   rect.top + rect.Height() / 2 + rcenter.y,
                   nOptions, rect, str, NULL);
}
sorry but he just started c++ today and made that code?
Quote Originally Posted by kibbles18 View Post
sorry but he just started c++ today and made that code?
He never said he made the code..So quit Whining
you obviously just copy and pasted that code and don't know anything about this subject
Quote Originally Posted by kibbles18 View Post
you obviously just copy and pasted that code and don't know anything about this subject
No he's a good coder Ive seen him around. What do you know about this subject @kibbles18? If you don't know any thing i keep the useless comments to a minimum.
Quote Originally Posted by NOOBJr View Post


No he's a good coder Ive seen him around. What do you know about this subject @kibbles18? If you don't know any thing i keep the useless comments to a minimum.
Did Someone leave there oven on?
Cause @kibbles18 just got burnt
Quote Originally Posted by NOOBJr View Post


No he's a good coder Ive seen him around. What do you know about this subject @kibbles18? If you don't know any thing i keep the useless comments to a minimum.
You retarded asshole, @kibbles18 was right. That code has nothing to do with this. Don't flame random people. Fucktard.
Quote Originally Posted by mmbob View Post


You retarded asshole, @kibbles18 was right. That code has nothing to do with this. Don't flame random people. Fucktard.
It wasn't a flame. I just said as i knew. He is a good coder and Kibbles was acting like he knew a lot about coding and ive never seen him here before. Anyways mmbob you have any functions for this?

- You just contradicted yourself if you think about it
Quote Originally Posted by NOOBJr View Post


It wasn't a flame. I just said as i knew. He is a good coder and Kibbles was acting like he knew a lot about coding and ive never seen him here before. Anyways mmbob you have any functions for this?

- You just contradicted yourself if you think about it
Kibbles said what was right. Just looking at that code you should have been able to tell it was useless for your needs. No, not yet.
directx sdk examples
Sorrry but, i don't know how to do this part?
"create a CFont with the angle of rotation specified in nEscapement."
Anyone know how? If not its cool Thanks
sry if i offended any1 i was mean
Posts 115 of 16 · Page 1 of 2

Post a Reply

Tags for this Thread

None

Need help?