Shop OBEX P1 Docs P2 Docs Learn Events
justification in gr.text (graphics) — Parallax Forums

justification in gr.text (graphics)

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2007-09-17 17:20 in Propeller 1
I'm attempting to do some calculated placement of text using "graphics"
I suspect that the 'justification' settings are getting in the way.

  gr.textmode(1,1,6,5) ' width, height, spacing
  gr.colorwidth(2,0) ' color, width
  gr.text(0,0,string("a"))




With this example, the placement of 0,0 should have set the "A" at left/middle of the screen,
instead it's middle/middle. I suspect it has to do with the 5 in the 'gr.textmode' command,
but I can't understand the bits explanation in graphics. It's as if it's auto-centering.

Could someone tell me how to turn the 'justify' off that is centering the text based on content?
I'd like to define the exact position of the text with col,row

If I add a few more letters to the string (change the "a" to "Jeff Ledger') then it starts to behave the way
I'd like it to. This still is a problem for me as I want exact placement of one letter at a time.
[noparse][[/noparse]Can this be done? Or do I just not see it?]


thanks!
Oldbitcollector

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

— Calvin, of 'Calvin and Hobbes.

Post Edited (Oldbitcollector) : 9/17/2007 1:18:33 AM GMT

Comments

  • RaymanRayman Posts: 14,162
    edited 2007-09-17 01:30
    I have trouble with that too... Text always comes out centered...
  • Mark BramwellMark Bramwell Posts: 56
    edited 2007-09-17 03:52
    I had the same problem. I wanted a string to be left justified and know exactly where every letter would appear.

    I used a loop to write 1 letter at a time. I used the loop-variable as part of the calculation to determine the horizontal position.

    -78 is how far to the left I wanted to start
    * 12 is the width of each letter
    FreqCounter is the Nth letter in the string (My string was 13 characters long)

    example:

    
      repeat FreqCounter from 1 to 13
        if DisplayedFreq[noparse][[/noparse]FreqCounter] <> NewFreq[noparse][[/noparse]FreqCounter] ' only display it if it has changed; stops the flicker
          bytemove(@TempSTR,@NewFreq[noparse][[/noparse]FreqCounter],1) ' move a single digit into our temp string
          gr.text(-78+(FreqCounter*12),55, @TempSTR) ' write a digit to a calculated screen position
          gr.finish
    
    
    
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-09-17 15:51
    Wow.. Ok, It isn't just me for once.. [noparse]:)[/noparse]

    Nice routine! Perhaps one of the .spin 'gods' might look at graphics to repair this issue.
    In the meantime, it seems I could simply pad the character with 12 empty spaces since all
    I'm doing in writing text left-to-right. As long as I keep track of my position, it "should"
    work.

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.

    — Calvin, of 'Calvin and Hobbes.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-17 17:20
    The ducmentation says:
    ''   justification  - bits[noparse][[/noparse]1..0]: 0..3 = left, center, right, left
    ''                    bits[noparse][[/noparse]3..2]: 0..3 = bottom, center, top, bottom
    


    So "5" WILL center the strings.

    Are you really sure it does not work with "0"??
Sign In or Register to comment.