Page Turn Effect?
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Page Turn Effect?
I would like to have a 'page turn' effect in my app -each 'page' will be a single window with image and text gadgets loaded when the page is 'turned'. If you have ever used Lotus Organizer, you will know what I mean.
Here is a similar sort of thing on line: library_events
Here is a similar sort of thing on line: library_events
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- Michael Vogel
- Addict
- Posts: 2806
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Page Turn Effect?
Not sure, how perfect you want to simulate the paper turning, but a quick approach could be something like this...
Code: Select all
#X=400
#Y=600
Procedure.s RandomLine()
Protected s.s
Protected i,c
c='A'
For i=1 To 40
s=s+Chr(c+Random(25))
If c<'a'
c='a'
ElseIf Random(10)=0
Select Random(10)
Case 0
s+". "
c='A'
Case 1
s+" "
c='A'
Default
s+" "
EndSelect
EndIf
Next i
ProcedureReturn s
EndProcedure
Procedure Page(p)
Protected i,j
Protected x
#Z=10
For i=1 To #Z
x=MulDiv_(#X,i,#Z)
StartDrawing(CanvasOutput(0))
DrawImage(ImageID(p+3),#X,0)
DrawImage(ImageID(p+1),#X,0,#X-x,#Y)
StopDrawing()
Delay(20)
Next i
For i=1 To #Z
x=MulDiv_(#X,i,#Z)
StartDrawing(CanvasOutput(0))
DrawImage(ImageID(p),0,0)
DrawImage(ImageID(p+2),#X-x,0,x,#Y)
StopDrawing()
Delay(20)
Next i
EndProcedure
Procedure Init()
Protected i,j,x,m,n,c
Protected s.s
OpenWindow(0,0,0,#X+#X,#Y,"")
CanvasGadget(0,0,0,#X+#X,#Y)
For i=1 To 20
CreateImage(i,#X,#Y)
StartDrawing(ImageOutput(i))
Box(0,0,#X,#Y,#White)
If i&1
m=#X
n=-1
Else
m=0
n=1
EndIf
For j=0 To 15
c=$10101*j*8+$808080
LineXY(m,0,m,#Y,c)
m+n
Next j
For j=1 To 28
DrawText(24,20*j,RandomLine(),#Black,#White)
Next j
s=Str(i)
If i&1
x=10
Else
x=#X-10-TextWidth(s)
EndIf
DrawText(x,#Y-20,Str(i),#Red,#White)
StopDrawing()
Next i
StartDrawing(CanvasOutput(0))
DrawImage(ImageID(1),0,0)
DrawImage(ImageID(2),#X,0)
StopDrawing()
EndProcedure
Procedure Main()
Init()
p=1
Repeat
Select WaitWindowEvent()
Case #WM_CHAR
Page(p)
If p<17
p+2
Else
p=1
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndProcedure
Main()
Re: Page Turn Effect?
I rarely have the need to barge in to a thread like this, but this is absolutely brilliant!Michael Vogel wrote:Not sure, how perfect you want to simulate the paper turning, but a quick approach could be something like this...
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Page Turn Effect?
Wow! That is just excellent, thank you Michael.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Page Turn Effect?
Just substitute this:heartbone wrote:But on Windows® only.
Code: Select all
x=(#X*i)/#Z
Code: Select all
x=MulDiv_(#X,i,#Z)
Brilliant code, by the way!
Regards,
Eric
Re: Page Turn Effect?

No.. not quite, I'll still need to figure out the Wal-Mart character. #WM_CHAR
Keep it BASIC.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Page Turn Effect?
So that's what it is!the Wal-Mart character. #WM_CHAR

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Page Turn Effect?
It just catches a keypress to turn the page. You can use a keyboard shortcut instead:heartbone wrote:No.. not quite, I'll still need to figure out the Wal-Mart character. #WM_CHAR
Code: Select all
Procedure Main()
Init()
p=1
AddKeyboardShortcut(0, #PB_Shortcut_Space, 1)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu
If EventMenu() = 1
Page(p)
If p<17
p+2
Else
p=1
EndIf
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndProcedure
Re: Page Turn Effect?
Hi IdeasVacuum,
Comic Book version based on Michael Vogel's page-turning effect:
- Comic Book / Magnifying Glass
Cheers!
Comic Book version based on Michael Vogel's page-turning effect:
- Comic Book / Magnifying Glass
Cheers!
Last edited by JHPJHP on Wed Feb 18, 2015 4:11 pm, edited 7 times in total.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Page Turn Effect?
That is a thing of beauty JHPJHP 

IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Page Turn Effect?
Nice one, Michael, thanks for sharing!
Also thanks to JHPJHP, nice example!
Also thanks to JHPJHP, nice example!
Stanley decided to go to the meeting room...
Re: Page Turn Effect?
Thank you IdeasVacuum, Karellen,
Applied a small update after noticing a slight flicker.
- page turning now initiated by mouse click
- should now be cross-platform
NB*: Update also includes various other improvements.
Cheers!
Applied a small update after noticing a slight flicker.
- page turning now initiated by mouse click
- should now be cross-platform
NB*: Update also includes various other improvements.
Cheers!
Last edited by JHPJHP on Fri Feb 13, 2015 1:55 am, edited 3 times in total.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Re: Page Turn Effect?
Very Nice
On Mac no effects without EventWindow...

On Mac no effects without EventWindow...
Code: Select all
Procedure Page(p)
Protected i,j
Protected x
#Z=10
For i=1 To #Z
x=MulDiv_(#X,i,#Z)
StartDrawing(CanvasOutput(0))
DrawImage(ImageID(p+3),#X,0)
DrawImage(ImageID(p+1),#X,0,#X-x,#Y)
StopDrawing()
Delay(10)
While WindowEvent() : Wend
Next i
For i=1 To #Z
x=MulDiv_(#X,i,#Z)
StartDrawing(CanvasOutput(0))
DrawImage(ImageID(p),0,0)
DrawImage(ImageID(p+2),#X-x,0,x,#Y)
StopDrawing()
Delay(10)
While WindowEvent() : Wend
Next i
EndProcedure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive