Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who is Online
46 user(s) are online (45 user(s) are browsing Forum)

Members: 0
Guests: 46

more...


Browsing this Thread:   1 Anonymous Users






Re: Slow start program with text size calculation (only first time!)
#4
Home away from home
Home away from home


See User information
@mrdarek Quote:
I decide use precalculated table with best fontsize for every 100 px screen from 200 to 2000 width

If I understand you right, I don't think that will *always* work, because there is no guarantee that someone will have exactly the same font as you, nor that their version of OS4 will render it exactly the same way.

Quote:
Function y=f(x) lettersize=f(gamenamesize) is not linear so calculation will be hard and different for different fonts.

That should not be a problem: You only need to assume it is linear (to get a rough estimate), and then do a few loops to improve your estimate. I suggest that 10 loops will probably be enough.

The mathematical Newton-Ralphson method does something like this, and it works pretty well for calculating curved things. (Don't bother to read-up on that method, it won't help you here, well unless you love maths.)

Posted on: 2011/4/19 7:50
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Slow start program with text size calculation (only first time!)
#3
Just can't stay away
Just can't stay away


See User information
OK,
Function y=f(x) lettersize=f(gamenamesize) is not linear so calculation will be hard and different for different fonts. I decide use precalculated table with best fontsize for every 100 px screen from 200 to 2000 width. it will be not scalable as I wish but gamename should be visible (readable) at any window size.

Posted on: 2011/4/18 17:41
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Slow start program with text size calculation (only first time!)
#2
Home away from home
Home away from home


See User information
@mrdarek
At a guess, OS4 is having to generate a HUGE number of (differently sized) fonts for your program, and this takes some time. But after the first run they are cached, and so your program runs fast.

So you need to fix your algorithm to try (a lot!) fewer font sizes. The simplest (and least effective) solution would be to make z3 increase in a larger (but still fixed) jump than +1.

A better solution would make a crude estimate of how large z3 needs to be, based on the difference between z1 & width (exactly what you do with that difference would take a bit of experimentation, although I have some good ideas). If you loop using your estimate, you need to be sure it can't get stuck in the loop (nor do lots of loops trying to get the "perfect" result), but I suspect you can get away with not using a loop.

Posted on: 2011/4/18 7:50
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Slow start program with text size calculation (only first time!)
#1
Just can't stay away
Just can't stay away


See User information
Now I try perfectly fit MyGameName in game window. My code is:
<pre>
PROC DrawBoardMenu()
SetColour(MakeRGB(col_a1,col_a2,col_a3))
DrawBox (0,0,width,height) -> board clear
SetColour(MakeRGB(col_c1,col_c2,col_c3))
z3:=15
REPEAT
z3++
-> SetFont('Nimbus Roman No9 L Medium', z3,4)
SetFont('Bitstream Vera Sans', z3,2)
z1,z2temp:=InfoSizeOfTextL('MyGameName',[])!!INT
UNTIL z1 >= (width-10)
z3--
-> SetFont('Nimbus Roman No9 L Medium', z3,4)
SetFont('Bitstream Vera Sans', z3,2)
DrawTextL (0,0,'MyGameName',[],$000000)

ENDPROC -> 'end DrawBoardMenu

</pre>
But first run this code take very long time - near 10 second!!! After closing and run again program work immediatelly. After reset amiga - again I need wait 10 second for first run...

How speed-up first run program?

Posted on: 2011/4/16 15:17
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4462
2 nikolaos
nikolaos
4206
3 magorium
magorium
4095
4 phoenixkonsole
phoenixkonsole
3942
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2810
7 mazze
mazze
2222
8 Kalamatee
Kalamatee
2212
9 clusteruk
clusteruk
2114
Powered by XOOPS © 2001-2025 The XOOPS Project