The following program uses FN OPENPICTURE to record a pict of a
line of text.
When the text is displayed with DRAWPICTURE the text
string is displayed 4 pixels further to the right than the
enclosing rectangle created with FRAMERECT.
I was recently advised:
<<fn stringwidth(theMsg) gives an exact measurement of the string. You
need an extra 2 pixels in order to actually draw the string.>>
If I activate lines 2 and 3 below, and REM out line 1 the string and the
rectangle display correctly (with a little extra space for the string).
My question is why do these functions behave this way? And do other
objects than text display in the same manner?
I would like to use this pict recording method to create a GWorld
program. I need to know that the source rectangle and its contents
that I am copying to another GWorld is where I think it is.
clear local
dim as rect pictRect
dim as long pictH
dim as str255 theMsg
dim height, wdth, charWdth
'~'1
local fn DoRects
text _courier,16,0
theMsg = "M testmessage...testmessage M"
height = usr fontheight
wdth = fn stringwidth(theMsg) '<-------- 1
'wdth = fn stringwidth(theMsg)+1 '<-------- 2
setrect(pictRect,0,0,wdth,height)
pictH = fn openpicture(pictRect)
pictRect = [pictH]+_picFrame
offsetrect(pictRect,-pictRect.left%,-pictRect.top%)
'moveto(1,height-4) '<----------- 3
drawstring(theMsg)
framerect(pictRect)
closepicture
drawpicture(pictH,pictRect)
end fn
WINDOW #1,"Rects",(0,0)-(500,100),261
FN DoRects
do
handleevents
until 0
--
To unsubscribe, send ANY message to: futurebasic-unsubscribe@...