Thread: Rotate Text

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    NOOBJr's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in NOOB
    Posts
    1,426
    Reputation
    112
    Thanks
    693

    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

  2. The Following User Says Thank You to NOOBJr For This Useful Post:

    NOOB (06-23-2011)

  3. #2
    Crash's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    JAville
    Posts
    2,889
    Reputation
    163
    Thanks
    3,290
    My Mood
    Sleepy
    Lol what a coincidence I was just needing that too...
    Apparently you need to use SetTransform
    Last edited by Crash; 05-17-2011 at 03:13 PM.

  4. The Following User Says Thank You to Crash For This Useful Post:

    NOOB (06-23-2011)

  5. #3
    OBrozz's Avatar
    Join Date
    May 2011
    Gender
    male
    Posts
    820
    Reputation
    65
    Thanks
    813

    [Answer] Rotate text


    @Zane Slayman, @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);
    }
    Last edited by OBrozz; 05-17-2011 at 04:30 PM.

  6. The Following 2 Users Say Thank You to OBrozz For This Useful Post:

    NOOB (06-23-2011),NOOBJr (05-17-2011)

  7. #4
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    124
    you obviously just copy and pasted that code and don't know anything about this subject

  8. The Following User Says Thank You to kibbles18 For This Useful Post:

    NOOB (06-23-2011)

  9. #5
    NOOBJr's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in NOOB
    Posts
    1,426
    Reputation
    112
    Thanks
    693
    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.

  10. The Following User Says Thank You to NOOBJr For This Useful Post:

    NOOB (06-23-2011)

  11. #6
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,170
    Reputation
    490
    Thanks
    2,253
    Quote Originally Posted by Zane Slayman 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

  12. The Following 3 Users Say Thank You to whit For This Useful Post:

    NOOB (06-23-2011),NOOBJr (05-17-2011),playerxero (05-17-2011)

  13. #7
    NOOBJr's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in NOOB
    Posts
    1,426
    Reputation
    112
    Thanks
    693
    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

  14. The Following User Says Thank You to NOOBJr For This Useful Post:

    NOOB (06-23-2011)

  15. #8
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    124
    sorry but he just started c++ today and made that code?

  16. The Following User Says Thank You to kibbles18 For This Useful Post:

    NOOB (06-23-2011)

  17. #9
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,170
    Reputation
    490
    Thanks
    2,253
    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

  18. The Following User Says Thank You to whit For This Useful Post:

    NOOB (06-23-2011)

  19. #10
    Crash's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    JAville
    Posts
    2,889
    Reputation
    163
    Thanks
    3,290
    My Mood
    Sleepy
    Quote Originally Posted by Zane Slayman 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.
    10 second Google search :
    Draw Rotate Text with GetTextExtent and SetTextAlign and ExtTextOut, VC++ Example

    Anyway you're better of googling it as well

  20. The Following User Says Thank You to Crash For This Useful Post:

    NOOB (06-23-2011)

  21. #11
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    124
    sry if i offended any1 i was mean

  22. The Following User Says Thank You to kibbles18 For This Useful Post:

    NOOB (06-23-2011)

  23. #12
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    655
    Reputation
    70
    Thanks
    1,156
    My Mood
    Bitchy
    Quote Originally Posted by Zane Slayman 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.

  24. #13
    NOOBJr's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in NOOB
    Posts
    1,426
    Reputation
    112
    Thanks
    693
    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
    Last edited by NOOBJr; 05-17-2011 at 05:46 PM.

  25. #14
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    655
    Reputation
    70
    Thanks
    1,156
    My Mood
    Bitchy
    Quote Originally Posted by Zane Slayman 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.

  26. #15
    SNal2F's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    175
    Reputation
    30
    Thanks
    99
    directx sdk examples

Page 1 of 2 12 LastLast