Qbasicnews.com

Full Version: Yagl text output
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone know how i would calculate the x-length of a string in pixels to be outputted by the Yagl text thingo?
You can use GfxFont::getTextDimensions (YaglGfxFont_getTextDimensions in the wrapper):

Code:
Dim font As YaglGfxFont
Dim text As String
Dim x As UInteger, y As UInteger

...

text = "Hello, world"

YaglGfxFont_getTextDimensions(font, text, x, y)
it doesn't seem to work the compiler yields the error
error 10: expected '=', found 'dispfont'
Could you post your code?
Code:
SUB makebutton (x1, y1, x2, y2, text$, idx)

z = buttonindex(idx)

If z = 0 Then leftcol = rgb(255, 255, 255): rightcol = rgb(200, 200, 200): fontcol = 0
If z = 1 Then leftcol = rgb(200, 200, 200): rightcol = rgb(255, 255, 255): fontcol = rgb(0, 0, 255)

YaglGfxDevice_SolidBox x1, y1, x2, y2, rgb(240, 240, 240), 1
YaglGfxDevice_Solidbox x1, y1, x2, y1 + 2, leftcol, 1
YaglGfxDevice_SolidBox x1, y1, x1 + 2, y2, leftcol, 1

YaglGfxDevice_SolidBox x2, y2, x2 - 2, y1, rightcol, 1
YaglGfxDevice_SolidBox x2, y2, x1, y2 - 2, rightcol, 1

YaglGfxFont_getTextDimensions dispfont, text$, strxlen, strylen
'YaglGfxFont_getTextDimensions


'strlen = len(text$) * 12

xlen = x2 - x1
ylen = y2 - y1
xdisp = (xlen - strxlen) \ 2

ydisp = (ylen - strylen) \ 2

YaglGfxDevice_Printat text$, x1 + xdisp, y1 + ydisp, fontcol, dispfont, 1



END SUB
Its ok i figured out what's wrong. for some reason the function is YagGfxDevice, and is missing an l.
Hmm, there's a typo in the latest released yaglwrapper.bi - change "YagGfxFont_getTextDimensions" to "YaglGfxFont_getTextDimensions" (add the "L").