Page 1 of 2
Page Turn Effect?
Posted: Wed Feb 11, 2015 1:30 am
by IdeasVacuum
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
Re: Page Turn Effect?
Posted: Wed Feb 11, 2015 7:24 pm
by Michael Vogel
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?
Posted: Wed Feb 11, 2015 11:04 pm
by bbanelli
Michael Vogel wrote:Not sure, how perfect you want to simulate the paper turning, but a quick approach could be something like
this...
I rarely have the need to barge in to a thread like this, but this is absolutely brilliant!
Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 3:14 am
by IdeasVacuum
Wow! That is just excellent, thank you Michael.
Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 3:08 pm
by heartbone
Very cool code
Michael Vogel.

But on Windows® only.

Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 3:58 pm
by ebs
heartbone wrote:But on Windows® only.

Just substitute this:
for this:
and no more Windows only!
Brilliant code, by the way!
Regards,
Eric
Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 4:01 pm
by heartbone
ebs, I'm sure that is true after those annoying color constants are defined or replaced.
No.. not quite, I'll still need to figure out the Wal-Mart character. #WM_CHAR
Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 4:23 pm
by IdeasVacuum
the Wal-Mart character. #WM_CHAR
So that's what it is!

Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 5:01 pm
by ebs
heartbone wrote:No.. not quite, I'll still need to figure out the Wal-Mart character. #WM_CHAR
It just catches a keypress to turn the page. You can use a keyboard shortcut instead:
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?
Posted: Thu Feb 12, 2015 5:49 pm
by JHPJHP
Hi IdeasVacuum,
Comic Book version based on Michael Vogel's page-turning effect:
-
Comic Book / Magnifying Glass
Cheers!
Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 6:37 pm
by IdeasVacuum
That is a thing of beauty JHPJHP

Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 6:38 pm
by Karellen
Nice one, Michael, thanks for sharing!
Also thanks to JHPJHP, nice example!
Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 7:46 pm
by davido
@
Michael Vogel
Brilliant!
Thank you for sharing.

Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 8:54 pm
by JHPJHP
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!
Re: Page Turn Effect?
Posted: Thu Feb 12, 2015 9:36 pm
by mk-soft
Very Nice
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