View Full Version : justification in gr.text (graphics)

Oldbitcollector (Jeff)
09-17-2007, 07:57 AM
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

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.
[Can this be done? Or do I just not see it?]


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

09-17-2007, 08:30 AM
I have trouble with that too... Text always comes out centered...

Mark Bramwell
09-17-2007, 10:52 AM
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)


repeat FreqCounter from 1 to 13
if DisplayedFreq[FreqCounter] <> NewFreq[FreqCounter] ' only display it if it has changed; stops the flicker
bytemove(@TempSTR,@NewFreq[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

Oldbitcollector (Jeff)
09-17-2007, 10:51 PM
Wow.. Ok, It isn't just me for once.. :)

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"


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

— Calvin, of 'Calvin and Hobbes.

09-18-2007, 12:20 AM
The ducmentation says:

'' justification - bits[1..0]: 0..3 = left, center, right, left
'' bits[3..2]: 0..3 = bottom, center, top, bottom

So "5" WILL center the strings.

Are you really sure it does not work with "0"??