Jump to content


Photo

APNG_LIB Animated PNG image queue system


  • Please log in to reply
15 replies to this topic

#1 LiquidGravity

LiquidGravity
  • Members
  • 154 posts

Posted 13 March 2011 - 12:05 AM

APNG_LIB.ahk v0.3 written by LiquidGravity (based loosely on the BRA Library BRA.ahk written by tic (Tariq Porter) and includes derRaphael's GDIP Canvas)
Version 0.3

Run APNG_Demo3.ahk written by LiquidGravity (based loosely on gdi+ ahk tutorial 11 written by tic (Tariq Porter))
Demonstrates animation of APNG images with a queue system

Requirements:
Requires Gdip.ahk written by tic (Tariq Porter) either in your Lib folder as standard library or using #Include http://www.autohotke...pic.php?t=32238
(included in Zip) Requires command line APNG Disassembler by Max Stepin http://sourceforge.n...ojects/apngdis/
(included in Zip) Requires List Functions Mod.ahk This is a modified version of Uberi's List Manipulation functions http://www.autohotke...pic.php?t=68313
(included in Zip) Demo additionally requires 2 APNG images

Recent Changes:
Version 0.1
- Initial semi-private release (that sounds dirty)

Version 0.2
- Private build
- Removed dependancy on list view and now uses a modified version of Uberi's List Manipulation functions <!-- m -->http://www.autohotke...pic.php?t=68313<!-- m -->
- Added functions such as 2dArrayList_Modify to alter an existing sprite.
- Changed demo to highlight more of the multi sprite queue system features.

Version 0.3
- First posted in the Scripts and Functions
- Added functions for checking what sprite(s) is/are under a specified location.
- Changed demo to now highlight these features as well.

Zip Download:
http://www.autohotke.../APNG_DEMO3.zip

Demo screenshot:
Posted Image

#2 sumon

sumon
  • Moderators
  • 1307 posts

Posted 13 March 2011 - 12:54 AM

Thanks for sharing. What are you using it for, or intending to use it for? To me, the menu buttons seemed useful - is that something you have done or is it coming from elsewhere and you just included it because it looks good?

Some feedback:

1) Upon closing the GUI, the script doesn't exit. Perhaps add an Esc:: hotkey?
2) Mousedown doesn't seem to work, except when I spamclick the buttons (and then also only temporarily). System info: Win7 x32 Laptop, AHK_L Unicode.

#3 LiquidGravity logged out

LiquidGravity logged out
  • Guests

Posted 13 March 2011 - 04:01 AM

Thanks for trying it.
This lib is very much a work in progress. I've been developing it out of necessity. AHK needs more accessable graphical methods for games and such. AHK Arena for example.
The buttons are something I made myself but would not be possible without learning from others code and also the supporting includes. By use of the same functions as the buttons use one could make animated units that are selectable. Which reminds me to add an area check for laso use.

To address your issues:
1) The gui is merely for demo purposes and as you can see from the right click menu can be brought back up as needed. I did this because I just liked to hide it and watch the animations sometimes. Lol
2) The mouse down is probably working but is immediately being over written by the mouse move if the mouse moves. I will probably add a check in the mouse move code to prevent this.

#4 Learning one

Learning one
  • Members
  • 1294 posts

Posted 14 March 2011 - 08:11 PM

Very nice demonstration! :D But after quickly looking at the lib code, I have one tip: do not use global functions & variables!

#5 LiquidGravity

LiquidGravity
  • Members
  • 154 posts

Posted 15 March 2011 - 03:38 AM

Thanks!
I agree about globals and it is on my 'to do list' already.

Unfortunately this happened and will take some of my time now. Luckly I uploaded this script just before so I can play a little.

#6 kenn

kenn
  • Members
  • 407 posts

Posted 16 March 2012 - 04:17 PM

OMG! LiquidGravity I read your post on tic's GDIP thread and I just noticed your examples, they look awesome, why on earth I didn't see them. I'm looking forward to your latest update. Good luck.

#7 LiquidGravity

LiquidGravity
  • Members
  • 154 posts

Posted 19 March 2012 - 05:11 AM

APNG_LIB.ahk v0.6 written by LiquidGravity (based loosely on the BRA Library BRA.ahk written by tic (Tariq Porter) and includes derRaphael's GDIP Canvas)
Version 0.6

Run APNG_DEMO_DRAG.ahk written by LiquidGravity (based loosely on gdi+ ahk tutorial 11 written by tic (Tariq Porter))
Demonstrates animation of APNG images, lines with a queue system.

Requirements:
Requires Gdip.ahk written by tic (Tariq Porter) either in your Lib folder as standard library or using #Include <!-- m -->http://www.autohotke...pic.php?t=32238<!-- m -->
(included in zip) Requires command line APNG Disassembler by Max Stepin <!-- m -->http://sourceforge.n...ojects/apngdis/<!-- m -->
(included in Zip) Requires List Functions Mod.ahk v.06 This is a modified version of Uberi's List Manipulation functions <!-- m -->http://www.autohotke...pic.php?t=68313<!-- m -->
(included in Zip) Demo additionally requires 2 APNG images.

Recent Changes:
Version 0.1
- Initial semi-private release (that sounds dirty)

Version 0.2
- Private build
- Removed dependancy on list view and now uses a modified version of Uberi's List Manipulation functions <!-- m -->http://www.autohotke...pic.php?t=68313<!-- m -->
- Added functions such as 2dArrayList_Modify to alter an existing sprite.
- Changed demo to highlight more of the multi sprite queue system features.

Version 0.3
- First posted in the Scripts and Functions
- Added functions for checking what sprite(s) is/are under a specified location.
- Changed demo to now highlight these features as well.

Version 0.4
- Added the ability to drag an area with the mouse and return an area selection list.
- Corrected parented sprites not showing clicks correctly.
- Added functions to support above feature.

Version 0.5
- Changed demo to highlight parent/child sprites.

Version 0.6
- Added the ability to drag an object.
- Added the ability to add lines with parents for both ends.
- Added functions to support above feature.

Zip Download:
<!-- w -->www.autohotkey.net/~LiquidGravity/APNG_DEMO_DRAG.zip<!-- w -->

Demo screenshot:
Posted Image

#8 LiquidGravity

LiquidGravity
  • Members
  • 154 posts

Posted 19 March 2012 - 05:19 AM

This is still very WIP and therefor a lot of the code is messy and lots of it will change every release. Please let me know your thoughts about it.

FYI things I plan to add into the system in the future are:
Text.
Support for more animations (fades, shades, rotation).
Make the lib work without using globals and such. - not as big a priority as getting more features working first.

#9 kenn

kenn
  • Members
  • 407 posts

Posted 19 March 2012 - 11:19 AM

LiquidGravity You code wizard congratulations! I believe most AHK users was waiting for such a library for a long time. Dragging overlapped transparent controls was unresolved issue of AHK. So your library solved that completely. I am very happy to see this. We can make Packman style games with this, right?. Thank you very much in the name of AHK community.

#10 kenn

kenn
  • Members
  • 407 posts

Posted 26 March 2012 - 02:18 PM

While dragging image slips away, can it be fixed to stay under mouse from beginning its initial position?

#11 LiquidGravity logged out

LiquidGravity logged out
  • Guests

Posted 27 March 2012 - 02:20 AM

Thanks! Its something I wanted to add, but wanted to release first. Basically, instead of passing only the mouse's current position - use a component of the mouse's current position and the position it was when first dragging.

There are a lot of things I want to add, so it will take time. Then after every feature is in there I will work on bug fixing and optimization.

#12 stevenp

stevenp
  • Members
  • 187 posts

Posted 21 June 2012 - 02:27 PM

I got an error after adding "few" sprites:
---------------------------
APNG_Demo3.ahk
---------------------------
Error in #include file "F:\Development\Scripting\AutoHotKey\Applications\Animated PNG\APNG_LIB.ahk":
     The following variable name contains an illegal character:
"TempAPNG1-106"

	Line#
	249: Parent_Y_Loc := 2dArrayList_Get(ListName,7,ParentNum)
	250: Draw_X_Loc := Parent_X_Loc + Queue_X_Loc
	251: Draw_Y_Loc := Parent_Y_Loc + Queue_Y_Loc
	252: }
	254: }
	256: %ListName%3 := StringElementInsert(%ListName%3,NextIndex,A_Index,1)
	257: Queue_CurrentIndex := Round(Queue_CurrentIndex)
--->	258: Gdip_DrawImage(G1, TempAPNG%Queue_FileNum%%Queue_CurrentIndex%, Draw_X_Loc, Draw_Y_Loc, Queue_Width, Queue_Height)  
	259: }
	260: if Delete_List is not space
	261: Loop,parse,Delete_List,|
	262: {
	264: 2dArrayList_DeleteRow(ListName,A_LoopField)  
	265: }
	266: UpdateLayeredWindow(hwnd1, hdc1)  

The current thread will exit.
---------------------------
OK   
---------------------------

to obtain a smoother animation, I've set the timer from 70 to 30 ms
SetTimer, Queue_Timer, 30
SetTimer, Mouse_Timer, 30
but that hits the CPU and dragging is not smooth anymore

#13 CodeEater

CodeEater
  • Members
  • 78 posts

Posted 21 June 2012 - 02:41 PM

I got an error...

You should post your code.
The problem may be caused by Queue_FileNum variable.

#14 stevenp

stevenp
  • Members
  • 187 posts

Posted 21 June 2012 - 03:51 PM

I didn't changed nothing in the APNG_Demo3.ahk script, just testing: added many sprites by clicking the "This is a Button" Button and the result is the Error Message which was posted above.

#15 CodeEater

CodeEater
  • Members
  • 78 posts

Posted 22 June 2012 - 05:17 AM

it works on my computer (tested with ahk_H and AHK basic), except for the mouse-down-image.