RE: Algorithmics
Thanks very much... That's several orders of magnitude quicker.
-----Original Message-----
From: Pete Lomax [mailto:petelomax at blueyonder.co.uk]
Subject: Re: Algorithmics
On Fri, 17 Jan 2003 11:47:31 +1100, Patrick.Barnes at transgrid.com.au
wrote:
>Can anyone see what could be improved?
A quick hack at a binary chop
Code may need cleaning a bit but seems to work:
integer bsize, ssize
--#START OF CODE THAT IS TOO SLOW#--
fsize = 8 --starting font size
ssize = 1
bsize = 0
while 1 do
--find the size of that text
setFont(win, "Times New Roman", fsize, Normal)
tsize = getMlTextExtent(win, lines, 0)
--if it's bigger than the window...
if tsize[1] >= wsize[1] or tsize[2] >= wsize[2] then
bsize=fsize
fsize=ssize+floor((fsize-ssize)/2)
if fsize=ssize then
exit
end if
else
ssize=fsize
if bsize=0 then
fsize*=2
else
if fsize+1=bsize then exit end if
fsize+=floor((bsize-fsize)/2)
end if
end if
end while
--#END OF CODE THAT IS TOO SLOW#--
Pete
==^^===============================================================
This email was sent to: Patrick.Barnes at transgrid.com.au
TOPICA - Start your own email discussion group. FREE!
***********************************************************************
***********************************************************************
|
Not Categorized, Please Help
|
|