[Example] ImageFrames.pb

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

[Example] ImageFrames.pb

Post by Flype »

Hello,

I see there is no Images Frames example in the distribution (the english one, at least).

Maybe that simple one is good enough for that purpose.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Image Frames example file
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

w = 320
h = 240

; Create an image with some frames

If CreateImage(0, w, h)
	For i = 0 To 50
		If AddImageFrame(0)
			If StartDrawing(ImageOutput(0))
				Circle(w / 2, h / 2, 2 * (i + 1), #Red)
				Circle(w / 2, h / 2, 1 * (i + 1), #Black)
				StopDrawing()
			EndIf
		EndIf
	Next
	SetImageFrame(0, 1)
	SetImageFrameDelay(0, 25)
EndIf

; Create a window and an image gadget

If OpenWindow(0, 0, 0, w, h, "Image Frames", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	
	ImageGadget(0, 0, 0, w, h, 0)
	
	AddWindowTimer(0, 0, GetImageFrameDelay(0))
	
	Repeat
		Select WaitWindowEvent()
			Case #PB_Event_Timer
				If GetImageFrame(0) < ImageFrameCount(0) - 1
					SetImageFrame(0, GetImageFrame(0) + 1)
				Else
					SetImageFrame(0, 1)
				EndIf
				SetGadgetState(0, ImageID(0))
			Case #PB_Event_CloseWindow
				Break
		EndSelect
	ForEver
	
	RemoveWindowTimer(0, 0)
	
EndIf
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1252
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: [Example] ImageFrames.pb

Post by Paul »

I see there is no Images Frames example in the distribution (the english one, at least).
There is, it's just hidden under "ImagePlugin" in the help file (ImagePlugin_GIF.pb) :shock:

Certainly wouldn't hurt to have an example closer to the actual command that is being referenced.
Image Image
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Re: [Example] ImageFrames.pb

Post by Flype »

Oh ok :) indeed got fooled by example naming, sorry.

It's because my need was not related to GIF, since i build anim on my own without loading or saving data.

[EDIT] Also i was thinking, when doing F1 for HELP, there was no example in those Functions descriptions.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply