Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. Draw Text Upside Down

Draw Text Upside Down

Scheduled Pinned Locked Moved Graphics
questioncsharpgraphicsalgorithmshelp
4 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WaveK89
    wrote on last edited by
    #1

    For a C# windows application I am working on, I am trying to draw actual poker cards. I haven't been able to figure out how to draw text upside down. (As such a number and suit will appear in the opposite corner upside down of the card) I have no problems with drawing a string normally. I was wondering if someone could point me in the right direction? I did some searching on the net, but I haven't been able to get clear cut results. From what I found, I'm thinking a matrix is what is needed to be used, but I'm not quite sure how this would work. My second question which is somewhat unrelated to the problem and isn't priority right now: Is it possible to draw an entire card and draw that card to a specifc location? I ask this because it might be easier to develop a card at a (0,0) point and place where it needs to be. Thank You.

    L T L 3 Replies Last reply
    0
    • W WaveK89

      For a C# windows application I am working on, I am trying to draw actual poker cards. I haven't been able to figure out how to draw text upside down. (As such a number and suit will appear in the opposite corner upside down of the card) I have no problems with drawing a string normally. I was wondering if someone could point me in the right direction? I did some searching on the net, but I haven't been able to get clear cut results. From what I found, I'm thinking a matrix is what is needed to be used, but I'm not quite sure how this would work. My second question which is somewhat unrelated to the problem and isn't priority right now: Is it possible to draw an entire card and draw that card to a specifc location? I ask this because it might be easier to develop a card at a (0,0) point and place where it needs to be. Thank You.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, 1. yes you can get there with a transformation matrix. The easier way is by calling TranslateTransform and RotateTransform. I suggest you first translate over (w/2, h/2) so the center of the card becomes (0,0), and the borders are at -w/2, +w/2, -h/2, +h/2. Then draw everything from there; the upside-down parts just take a single RotateTransform over 180 degrees. Remark: each transformation is added to the existing ones, so either do the upside-down parts (with RotateTransform) last, or have them followed by another rotation to undo the previous one for everything you will paint later on in the Paint handler. Hint: it is quite easy to make a sign mistake, which will lead to everything being drawn outside the visible area, therefore I typically start of by drawing small things in a big area, and when things look about right, I set the normal sizes. 2. To draw several cards on a playground, you could draw a single card into a card-size bitmap using Graphics.FromImage; then use such bitmapped cards as images to be painted anywhere on your Form, your Panel, or another much larger bitmap. Alternatively you could precede a card drawing method by yet another translation (and even a rotation) to paint each card at its dedicated location and rotation on a playground. 3. I would be inclines to come up with a single static method DrawCard, taking the following parameters: - Graphics - Card Location - Card Size - Card Orientation - Card Value (52 plus backside, Joker, ...) And then you could build a DrawHand on top of that, etc. 4. Have a look at Graphics.ResetTransform, it may help you to reset things in between cards. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


      1 Reply Last reply
      0
      • W WaveK89

        For a C# windows application I am working on, I am trying to draw actual poker cards. I haven't been able to figure out how to draw text upside down. (As such a number and suit will appear in the opposite corner upside down of the card) I have no problems with drawing a string normally. I was wondering if someone could point me in the right direction? I did some searching on the net, but I haven't been able to get clear cut results. From what I found, I'm thinking a matrix is what is needed to be used, but I'm not quite sure how this would work. My second question which is somewhat unrelated to the problem and isn't priority right now: Is it possible to draw an entire card and draw that card to a specifc location? I ask this because it might be easier to develop a card at a (0,0) point and place where it needs to be. Thank You.

        T Offline
        T Offline
        Tim Craig
        wrote on last edited by
        #3

        And since playing cards usually have symmetry (unless you're planning on the Tijuana type ;P), you could draw half the card and complete the rest with two flips, one horizontal and one vertical, and a translation of the first half. The backs usually have even more symmetry and you could get away with drawing a quarter and flipping and translating to fill in the rest. The efficiency of doing so, of course, depends on the intricacy of the patterns you're using.

        You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

        1 Reply Last reply
        0
        • W WaveK89

          For a C# windows application I am working on, I am trying to draw actual poker cards. I haven't been able to figure out how to draw text upside down. (As such a number and suit will appear in the opposite corner upside down of the card) I have no problems with drawing a string normally. I was wondering if someone could point me in the right direction? I did some searching on the net, but I haven't been able to get clear cut results. From what I found, I'm thinking a matrix is what is needed to be used, but I'm not quite sure how this would work. My second question which is somewhat unrelated to the problem and isn't priority right now: Is it possible to draw an entire card and draw that card to a specifc location? I ask this because it might be easier to develop a card at a (0,0) point and place where it needs to be. Thank You.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          WaveK89 wrote:

          I am trying to draw actual poker cards.

          If you want to use a ready made library there is some good information here[^].

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups