In a recent post, Ricardo111 wanted to show an animation while a long process was running.
I proposed to animate text instead and my script seemed to please.
So I worked a bit more on it, to allow to easily add other animations (a kind of splash screen framework), while being #Includable in other scripts (you can keep only one animation to make this file lighter - beware of dependencies!).
The result can be downloaded: AnimatedSplashScreens.ahk. ( SKAN's Dropbox )
I also added a demo code with a little GUI.
It is a bit light on the comments but I hope its usage will be clear.
Animated Splash Screens
Started by
PhiLho
, Jun 13 2006 01:52 PM
15 replies to this topic
#1
-
Posted 13 June 2006 - 01:52 PM
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Dear PhiLho,
Nice Work!
My favorite is RandomZoom!
Regards,
PS: I am getting an error (when A_Index reaches 75, I guess). Please look into it.
Nice Work!
My favorite is RandomZoom!
Regards,
PS: I am getting an error (when A_Index reaches 75, I guess). Please look into it.
#2
-
Posted 14 June 2006 - 12:58 PM
Argh! I think we have reached a limit of AutoHotkey, which isn't designed for such silly use. ^_^'
I cannot see a workaround, as you have to declare the font before affecting it to a control. I suppose AHK stores each created font in an array of limited siz, and never release them. (Perhaps it could release the previous font when assigning a new?)
Alas, we cannot create the different font sizes in advance and reuse them, because there is no way to reference them.
So, we are stuck.
Thanks for reporting the problem.
I cannot see a workaround, as you have to declare the font before affecting it to a control. I suppose AHK stores each created font in an array of limited siz, and never release them. (Perhaps it could release the previous font when assigning a new?)
Alas, we cannot create the different font sizes in advance and reuse them, because there is no way to reference them.
So, we are stuck.
Thanks for reporting the problem.
#3
-
Posted 14 June 2006 - 01:22 PM
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
I ran into this error recently. Writing some simple presentation software in ahk (a BIT like Powerpoint) I set the mouse wheel to dynamically changing the font size and after a while I get the same error message. I checked the source code and ahk only allocates room for MAX_GUI_FONTS which is set at 100. It does check to see whether a font already exists before allocating a new one.
here are some suggestions:
* Keep a table of fonts in use(displaying data on screen) and override those that aren't as need be
* Enabling an option for the programmer to set:
#GuiResources low|med|high|unlimited
where low is the default, med is more and high is really high.
* bump the font number up to 1000. (not a solution - you just run into the problem later)
here are some suggestions:
* Keep a table of fonts in use(displaying data on screen) and override those that aren't as need be
* Enabling an option for the programmer to set:
#GuiResources low|med|high|unlimited
where low is the default, med is more and high is really high.
* bump the font number up to 1000. (not a solution - you just run into the problem later)
#4
-
Posted 15 June 2006 - 12:28 AM
Interesting ideas; thanks.
I could use clarification on what strategies require more than 100 fonts, and how many fonts would be sufficient (maybe an unlimited number is required). As mentioned above, since fonts are cached, a script would need to access more than 100 unique fonts to trigger this error. Accessing 70 fonts 10 times each wouldn't be enough to trigger it.
When I say "font" above, I really mean a combination of typeface + size + style, so that might explain why the limit is reached more easily.
Thanks.
I could use clarification on what strategies require more than 100 fonts, and how many fonts would be sufficient (maybe an unlimited number is required). As mentioned above, since fonts are cached, a script would need to access more than 100 unique fonts to trigger this error. Accessing 70 fonts 10 times each wouldn't be enough to trigger it.
When I say "font" above, I really mean a combination of typeface + size + style, so that might explain why the limit is reached more easily.
Thanks.
#5
-
Posted 15 June 2006 - 12:47 AM
Here is a sample of the code I'm using that requires potentially many combinations of font/size/weight/color? etc.
It is intended to be a presentation engine for displaying song words on a projector screen but is really just exploring the potential of ahk for such a job.
As you can see at any one time I only really need just one font being displayed but require the ability to choose among many. If you run the code and scroll the mousewheel or rightclick and change the font you'll get the idea.
For the purposes of this application you might not hit the size issue. I did because I was testing different fonts at different sizes to see how they looked. It would be nice to have flexibility to ignore arbritary limitations if possible by using a setting in the code such #GuiResources unlimited.
Certainly animation of text is another situation where numerous font combinations is needed - if my code develops a little further that may be a possible feature.
It is intended to be a presentation engine for displaying song words on a projector screen but is really just exploring the potential of ahk for such a job.
As you can see at any one time I only really need just one font being displayed but require the ability to choose among many. If you run the code and scroll the mousewheel or rightclick and change the font you'll get the idea.
For the purposes of this application you might not hit the size issue. I did because I was testing different fonts at different sizes to see how they looked. It would be nice to have flexibility to ignore arbritary limitations if possible by using a setting in the code such #GuiResources unlimited.
Certainly animation of text is another situation where numerous font combinations is needed - if my code develops a little further that may be a possible feature.
#SingleInstance Force Colors=Red,Green,Blue,Yellow,Black,White AvailableFonts=Arial,Tahoma,Verdana,Courier New,Times loop, parse, Colors, `, { Menu, FGColor, Add, %A_LoopField%, FGColorMenuHandler Menu, BGColor, Add, %A_LoopField%, BGColorMenuHandler } loop, parse, AvailableFonts, `, { Menu, FontMenu, Add, %A_LoopField%, FontMenuHandler } Menu, TextAlignMenu, Add, Right, TextAlignMenu Menu, TextAlignMenu, Add, Left, TextAlignMenu Menu, TextAlignMenu, Add, Center, TextAlignMenu Menu, ContextMenu, Add, Background Color, :BGColor Menu, ContextMenu, Add, Foreground Color, :FGColor Menu, ContextMenu, Add, Font, :FontMenu Menu, ContextMenu, Add, Align, :TextAlignMenu Menu, FileMenu, Add, &Exit, FileMenuHandler Menu, MenuBar, Add, &File, :FileMenu Gui, Menu, MenuBar Text=Here is the first line of Text to show`nand this is the second one much like the first`nThe third is also quite similar and`nIs now followed by the fourth line which ends here. WindowTitle=SmartSong WinWidth=%A_ScreenWidth%;800 WinHeight=%A_ScreenHeight%;600 TextWidth := WinWidth TextHeight := WinHeight Font=Verdana FontWeight=1000 FontSizer = 24 FontSize := FontSizer Gui +ToolWindow Gui, color, white Gui, Font, s%FontSize% w%FontWeight%, %Font% Gui, Add, Text,x0 y0 w%TextWidth% h%TextHeight% vPageText,%Text% Gui, Show, w%WinWidth% h%WinHeight%, %WindowTitle% return WheelUp:: ifWinActive, %WindowTitle% { FontSizer++ if FontSizer > 72 FontSizer = 72 else Gui, Font, s%FontSizer% GuiControl, Font, PageText } else { Send, {WheelUp} } return WheelDown:: ifWinActive, %WindowTitle% { FontSizer-- if FontSizer < 8 FontSizer = 8 else Gui, Font, s%FontSizer% GuiControl, Font, PageText } else { Send, {WheelDown} } return GuiContextMenu: Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY% return ContextMenuHandler: msgbox, You selected %A_ThisMenuItem% return FileMenuHandler: ExitApp return FontMenuHandler: Gui, Font,,%A_ThisMenuItem% GuiControl,Font,PageText return BGColorMenuHandler: Gui, Color, %A_ThisMenuItem% return FGColorMenuHandler: Gui, Font, c%A_ThisMenuItem% GuiControl, Font, PageText return TextAlignMenu: GuiControl,+%A_ThisMenuItem%,PageText return GuiClose: ExitApp
#6
-
Posted 15 June 2006 - 01:30 AM
Thanks for the example (more are welcome from anyone). The limit of 100 fonts was chosen to conserve memory and also because it was more fonts than I expected anyone would ever use in a single script. That limit can be increased, but it would help to know if there is any practical, real-world need for it (you mentioned a theoretical/testing script, which although it would be nice to support, probably isn't a high priority).
Anyway, I've made a note to see what can be done about it. Furthermore, I expect that font management will be streamlined a bit sometime down the road.
Thanks.
Anyway, I've made a note to see what can be done about it. Furthermore, I expect that font management will be streamlined a bit sometime down the road.
Thanks.
#7
-
Posted 15 June 2006 - 03:26 AM
OK, I have put a log of the used fonts, just by adding FileAppend %ASS_size%`n, FontSizeList.txt after the Gui Font command. A little C:\PrgCmdLine\Unix\sort.exe -u FontSizeList.txt | wc shows that I reached 99 distinct font sizes. Looking at these, I saw negative font values, and values beyond the maximum. And indeed, it goes ugly sometime.
I improved my algorithm a bit, and now it uses 41 fonts as expected (any value between 8 and 48). So, it should no more crash, unless you change the initial font size to something big (above 107 or 106).
I uploaded the improved script.
Chris, a suggestion on a better font use. It may not solve the base problem, but it may ease the use of fonts, and perhaps help controlling what is used.
Currently, when we want to change a font, and go back to a previous one, we have to redeclare most of it:
Gui Font, s16 cBlack, Broadway
Gui Add, Text, , This is
Gui Font, s16 cRed italic, Broadway
Gui Add, Text, x+5, just
Gui Font, s16 cBlack norm, Broadway
Gui Add, Text, x+5, an example
Gui Show
Actually, it isn't really necessary to do full declaration, as one font inherits from the previous one:
Gui Font, s16 cBlack, Broadway
Gui Add, Text, , This is
Gui Font, cRed italic
Gui Add, Text, x+5, just
Gui Font, cBlack norm
Gui Add, Text, x+5, an example
Gui Show
But it would be nice to be able to create a font object and refers to it:
Gui Font, s16 cBlack vblackFont, Broadway
Gui Font, s16 cRed italic vredFont, Broadway
Gui Add, Text, fblackFont, This is
Gui Add, Text, fredFont x+5, just
Gui Add, Text, fblackFont x+5, an example
I am not sure here if fonts declared this way still inherit from the previous one or not. I suppose they should, to avoid surprises...
Declaring alternative fonts may be tricky, but we could use something like:
Gui Font, s%size% w800 cLime vf%size%, Arial
Gui Font, rf%size%, Helvetica
(r as reference...)
BTW, when I write:
gui, font,, MS sans serif
gui, font,, Arial
gui, font,, Verdana ; Preferred font
does AHK create three fonts (if all fonts are available) or only the latest fitting one?
Back to my idea, I don't know if it is useful (widely used) enough to be worth implementing. It shouldn't generate too much code, anyway. What do you think of it?
I improved my algorithm a bit, and now it uses 41 fonts as expected (any value between 8 and 48). So, it should no more crash, unless you change the initial font size to something big (above 107 or 106).
I uploaded the improved script.
Chris, a suggestion on a better font use. It may not solve the base problem, but it may ease the use of fonts, and perhaps help controlling what is used.
Currently, when we want to change a font, and go back to a previous one, we have to redeclare most of it:
Gui Font, s16 cBlack, Broadway
Gui Add, Text, , This is
Gui Font, s16 cRed italic, Broadway
Gui Add, Text, x+5, just
Gui Font, s16 cBlack norm, Broadway
Gui Add, Text, x+5, an example
Gui Show
Actually, it isn't really necessary to do full declaration, as one font inherits from the previous one:
Gui Font, s16 cBlack, Broadway
Gui Add, Text, , This is
Gui Font, cRed italic
Gui Add, Text, x+5, just
Gui Font, cBlack norm
Gui Add, Text, x+5, an example
Gui Show
But it would be nice to be able to create a font object and refers to it:
Gui Font, s16 cBlack vblackFont, Broadway
Gui Font, s16 cRed italic vredFont, Broadway
Gui Add, Text, fblackFont, This is
Gui Add, Text, fredFont x+5, just
Gui Add, Text, fblackFont x+5, an example
I am not sure here if fonts declared this way still inherit from the previous one or not. I suppose they should, to avoid surprises...
Declaring alternative fonts may be tricky, but we could use something like:
Gui Font, s%size% w800 cLime vf%size%, Arial
Gui Font, rf%size%, Helvetica
(r as reference...)
BTW, when I write:
gui, font,, MS sans serif
gui, font,, Arial
gui, font,, Verdana ; Preferred font
does AHK create three fonts (if all fonts are available) or only the latest fitting one?
Back to my idea, I don't know if it is useful (widely used) enough to be worth implementing. It shouldn't generate too much code, anyway. What do you think of it?
#8
-
Posted 15 June 2006 - 09:54 AM
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Hej PhilLo.
This is very cool.
After visiting your site, I guess you can't control yourself when graphics is in question 8)
Maybe you should create OpenGL extension to AHK
And then release another, even better looking splashscreen framework
This is very cool.
After visiting your site, I guess you can't control yourself when graphics is in question 8)
Maybe you should create OpenGL extension to AHK
And then release another, even better looking splashscreen framework
#9
-
Posted 15 June 2006 - 09:59 AM
Curiously enough, I haven't studied yet OpenGL nor DirectX, mostly because of lack of time.
Note that it is fun to play with constraints, it reminds me when I was trying to make good looking screens with alphanumeric terminals, including a wait icon displaying successively / - \ | (big animation! :-)).
Note that it is fun to play with constraints, it reminds me when I was trying to make good looking screens with alphanumeric terminals, including a wait icon displaying successively / - \ | (big animation! :-)).
#10
-
Posted 15 June 2006 - 10:52 AM
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Yeah, I know what you mean (especialy that about time)
Anyway, look what some cool people did with OpenGl
http://www.novell.co...nux/xglrelease/
Then, go, and download Live CD and I garantee that you will not be able to beleive what you see.
Anyway, look what some cool people did with OpenGl
http://www.novell.co...nux/xglrelease/
Then, go, and download Live CD and I garantee that you will not be able to beleive what you see.
#11
-
Posted 15 June 2006 - 11:12 AM
My impression is that most people do not switch fonts that often in GUI design (and perhaps even less often do they use more than one or two typefaces). Therefore, the benefit/cost ratio seems unfavorable. However, contrary opinions are welcome.But it would be nice to be able to create a font object and refer to it
One of the costs of adding new features is hidden: it's the documentation complexity. For example, even if a new feature were easy to implement and very small in code size, documenting it would make the GUI feature seem more complex and harder to learn/remember. On the other hand, a feature may well have enough compelling benefits to justify these costs.
It will create all three (if they exist). However, this is an implementation detail that might be optimized in the future. As someone mentioned above, code could be added to do "garbage collection" to delete unused fonts each time a GUI window is destroyed.when I write:
gui, font,, MS sans serif
gui, font,, Arial
gui, font,, Verdana ; Preferred font
does AHK create three fonts (if all fonts are available) or only the latest fitting one?
#12
-
Posted 16 June 2006 - 12:05 AM
argh!
Why didn't I find this earlier?!? :x >pathetic 5-year old stomp<
for my loading animation, I used an image-changing loop on a fullscreen gui, and a dropping effect.
see My Google site
Why didn't I find this earlier?!? :x >pathetic 5-year old stomp<
for my loading animation, I used an image-changing loop on a fullscreen gui, and a dropping effect.
see My Google site
Loop { sleep,100 pic++ if pic=37 break guicontrol,,Static1, loading_animation\%pic%.bmp } sleep,1000 current:=(a_screenheight-67)/2 ;the super- cool animated drop (so i'm being slightly sarcastic) loop, 33 { x:=50-a_index sleep,%x% y:=a_index-4 current:=current+y guicontrol, move, Static1,% " x" (a_screenwidth-185)/2 " y" current }
#13
-
Posted 27 June 2006 - 11:26 PM
I can't access the script...
Neither per direct click nor via "Save target as.."
Thalon
Neither per direct click nor via "Save target as.."
Thalon
#14
-
Posted 28 June 2006 - 06:25 AM