Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Animated Splash Screens


  • Please log in to reply
15 replies to this topic
PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
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.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear PhiLho, :)

Nice Work! :D
My favorite is RandomZoom!

Regards, :)

PS: I am getting an error (when A_Index reaches 75, I guess). Please look into it.
kWo4Lk1.png

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
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.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

MisterW
  • Members
  • 65 posts
  • Last active: Jun 18 2007 11:14 AM
  • Joined: 20 Jul 2005
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)

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.

MisterW
  • Members
  • 65 posts
  • Last active: Jun 18 2007 11:14 AM
  • Joined: 20 Jul 2005
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.


#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


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
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?
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
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 :p
Posted Image

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
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! :-)).
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
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. :)
Posted Image

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

But it would be nice to be able to create a font object and refer to it

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.

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.

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?

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.

1991
  • Members
  • 29 posts
  • Last active: Jun 04 2007 03:05 AM
  • Joined: 20 Jan 2006
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
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
}


Thalon
  • Members
  • 641 posts
  • Last active: Jan 02 2017 12:17 PM
  • Joined: 12 Jul 2005
I can't access the script...
Neither per direct click nor via "Save target as.."

:(
Thalon

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear Thalon, :)

I can't access the script...
Neither per direct click nor via "Save target as.."


There are some difficulties right now @ autohotkey.net. See this post.

Here is my copy of the script : ( Redundant - Edited out )

Regards, :)
kWo4Lk1.png