Title "QB64 Script"
Input "Input text script file name:"; script$
'-------------------------------------- LOAD TO MEMORY AND CHECK ALL FILES IF EXISTS [STEP 1/3] ----------------------------------------------------------
'ziskat cas
Tim$
= Mid$(s$
, 1, sep
- 1) Tim$
= Mid$(Tim$
, sep
+ 1) Tim$
= Mid$(Tim$
, sep
+ 1)
'cas: Min, Sec, Set
Time = (Min * 60) + Secs + (Set / 100)
My(record).Time = Time
'ziskat prikaz (cmd$)
My(record).Statement = (s$)
cmd$
= Left$(s$
, sep
- 1)
Case "SCRN" ' Screen settings 'ziskat ResX
'ziskat ResY
Case "SIMG" ' Load images to array (in my mind is already upgrade for it) FileName$
= Mid$(s$
, sep
+ 1) If Images
(iU
) = -1 Then Print "Error: Image file "; FileName$;
" is in unsupported format.":
Sleep 3:
End Print "SIMG File "; FileName$;
" not found. (Record nr."; record;
")":
Sleep 3:
End
' Load images to array as SIMG statement, but PASS is for other use than SIMG (look again)
PhotoA$
= Mid$(s$
, sep
+ 1)
sep2 = InStrRev(s$, " ")
PassE(psI) = Effect
psI = psI + 1
If Images
(iU
) = -1 Then Print "Error: Image file "; PhotoA$;
" is in unsupported format.":
Sleep 3:
End Print "PASS File "; PhotoA$;
" not found. (Record nr."; record;
")":
Sleep 3:
End
Case "SNDL", "SNDP" ' Load sounds to array FileName$
= Mid$(s$
, sep
+ 1) Sounds(sU) = SndOpen(FileName$)
If Sounds
(sU
) = 0 Then Print "Error: Sound file: "; FileName$;
" is in unsupported format,":
Sleep 3:
End
Case "SVID" ' Load video file names (if file exists) to array as string (will be used later with Windows Media Player) FileName$
= Mid$(s$
, sep
+ 1) Videos(vU) = FileName$
Case "FONT" ' Load font TTF, OTF file sep2 = InStrRev(s$, " ")
FontName$
= Mid$(s$
, sep
+ 1, sep2
- sep
) Fonts(fU) = LoadFont(FontName$, FontSize, "MONOSPACE")
record = record + 1
ReDim Preserve My
(record
) As Content
Print "Error: Script text file "; script$;
" not exists."
' ------------------------------------- RUN OWN PRESENTATION [STEP 2/3] -------------------------------------------------------------------------------
R = 0
'time is calculated from TIMER
If Timer < NullTime
Then NullTime
= Timer - P_time
'midnight overflow check / not tested
'this is console developing window, it show presentation time for us. If presentation time is the same as in your script file, then it run again, otherwise program wait.
P_time
= Timer - NullTime
P_time
= Timer - NullTime
Dest Console
Echo
Str$(P_time
): Echo
Str$(My
(R
).Time
) Delay .01
Dest 0
'od 05-02-2022
Case "SIMG" ' command: Show Image (accept ratio) If PixelSize
= 4 Then ' works just if SCRN stetement for setting graphic screen is in text file used before SIMG statement, otherwise is this skipped! GetImageRatio LUX, LUY, RUX, RUY, imgI
_PutImage (LUX
, LUY
)-(RUX
, RUY
), Images
(imgI
) imgI = imgI + 1
If SndPlaying
(Sounds
(SoundsI
)) = 1 Then SndStop Sounds
(SoundsI
) 'Play sound in loop SndLoop Sounds(SoundsI)
SoundsI = SoundsI + 1
If SndPlaying
(Sounds
(SoundsI
)) = 1 Then SndStop Sounds
(SoundsI
) 'Play sound once SndPlay Sounds(SoundsI)
SoundsI = SoundsI + 1
SndStop Sounds(SoundsI)
Case "PASS" ' insert a transition between photos / videos 'parameter is OPTIONAL! Parameter = PassE(passI)
passI = passI + 1
InsertTransmission Parameter
Case "DELA" ' DELA statement is the same as SLEEP, it also stop time in presentation Parameter
= Val(Mid$(My
(R
).Statement
, 5))
StopTime
= Timer - NullTime
NullTime = StopTime
NullTime
= Timer - StopTime
Case "SVID" ' For future version - PlayVideo in this version is empty SUB, in future it use SpriggsySpriggs libraries for call Windows Media Player VideoName$ = Videos(VideoI)
VideoI = VideoI + 1
PlayVideo VideoName$
Case "FONT" ' View FONT. Use in file: ú[00:00:10] FONT Arial.ttf 40 <---- in step 1/3 it loads and in step 2/3 it view all text using Arial font size 40 Font Fonts(FontI)
FontI = FontI + 1
Text$
= Mid$(My
(R
).Statement
, 5) ' Print SUBTITLE to screen (just one row in this version) use in file is: [01:00:97] STIT This is subtitle InsertText Text$
Cls , RGB32
(Clrs
(0), Clrs
(1), Clrs
(2)) ' clear screen using color sets for foreground or for background color Case "COLF" ' set foreground color for subtitles (STIT statement) n$
= Mid$(My
(R
).Statement
, 5) 'Print n$
control
= InStr(nr$
, " ")
Color RGB32
(Clrs
(0), Clrs
(1), Clrs
(2))
Case "COLB" ' set background color n$
= Mid$(My
(R
).Statement
, 5) 'Print n$
control
= InStr(nr$
, " ")
Color , RGB32
(Clrs
(0), Clrs
(1), Clrs
(2))
Case "TEXT" ' Print centered text to screen. Use in file: [02:00:99] TEXT Here place long text which is then centered and printed to screen n$
= Mid$(My
(R
).Statement
, 5) LongText n$
FullScreen
R = R + 1
If R
> record
Then Exit Do 'skip to phase 3 - erasing RAM and quit.
'-------------------------------------- Erase RAM, delete images and sounds from memory and then end [Step 3/3] -----------------------------------------
FreeImage Images(C1)
SndClose Sounds(C2)
TextLenght = PrintWidth(T$)
Middle
= Width \
2 - TextLenght \
2 PrintMode KeepBackground
PrintString (Middle, Height - FontHeight - 10), T$
TextMax
= Width \ FontWidth
y = Height / 2 - (FontHeight * Rows / 2)
Tr = 1
t$ = t$ + " "
Word$
= Mid$(t
, Tr
, TextMax
) LastSpace = InStrRev(Word$, " ")
S$
= Mid$(Word$
, 1, LastSpace
) Center
= Width / 2 - PrintWidth
(S$
) / 2 PrintString (Center, y), S$
y = y + FontHeight
t$
= Mid$(t$
, LastSpace
+ 1)
'prechody fotek, 0 = nahodny
Old = CopyImage(0, 32)
New
= NewImage
(Width, Height
, 32) GetImageRatio lux, luy, rdx, rdy, imgI
_PutImage (lux
, luy
)-(rdx
, rdy
), Images
(imgI
), New
imgI = imgI + 1
s = 0
centerY = Height \ 2
Case 1 'old image shift up, new is shift from bottom PutImage (0, s), Old, 0
PutImage (0, s + Height), New, 0
s = s - 10
Case 2 'old photo go down, new is shift from ceil PutImage (0, s), Old, 0
PutImage (0, s - Height), New, 0
s = s + 10
Case 3 'old photo is shifted to right, new is comming from left PutImage (s, 0), Old, 0
PutImage
(s
- Width, 0), New
, 0 s = s + 10
Case 4 'old photo is shifted to left and new photo is comming from right PutImage (s, 0), Old, 0
PutImage
(s
+ Width, 0), New
, 0 s = s + 10
Case 5 'old photo is rewrited by circle contains new photo MapTriangle
(centerX
, centerY
)-(x1
, y1
)-(x2
, y2
), New
To(centerX
, centerY
)-(x1
, y1
)-(x2
, y2
), 0 s = s + .01
Display
Delay .2
AutoDisplay
Case 6 ' new photo is zoomed from middle the screen as rectangle with this image
Stp2 = Height / 100
x1
= centerX
+ Sin(3.925) * k
x1
= centerX
+ Sin(3.925) * k
y1
= centerY
+ Cos(3.925) * k2
x3
= centerX
+ Sin(0.785) * k
y3
= centerY
+ Cos(0.785) * k2
PutImage (x1, y1)-(x3, y3), New, 0
k = k + Stp
k2 = k2 + Stp2
kk = kk + 1
Delay .01
Case 7 'new photo is inserted as rectnagles from left to right and from ceiling to bottom
sy = Height / 10
PutImage (x, y), New, 0, (x, y)-(x + sx, y + sy)
Delay .02
Case 8 'vice versa as Case 7
sy = Height / 10
PutImage (x, y), New, 0, (x, y)-(x + sx, y + sy)
Delay .02
Case 9 'photo is displayed using quarter circle effect
x6
= centerX
+ Cos(s
+ .01 + 2 * c
) * Width y6
= centerY
+ Sin(s
+ .01 + 2 * c
) * Width
x8
= centerX
+ Cos(s
+ .01 + 3 * c
) * Width y8
= centerY
+ Sin(s
+ .01 + 3 * c
) * Width
MapTriangle
(centerX
, centerY
)-(x1
, y1
)-(x2
, y2
), New
To(centerX
, centerY
)-(x1
, y1
)-(x2
, y2
), 0 MapTriangle
(centerX
, centerY
)-(x3
, y3
)-(x4
, y4
), New
To(centerX
, centerY
)-(x3
, y3
)-(x4
, y4
), 0 MapTriangle
(centerX
, centerY
)-(x5
, y5
)-(x6
, y6
), New
To(centerX
, centerY
)-(x5
, y5
)-(x6
, y6
), 0 MapTriangle
(centerX
, centerY
)-(x7
, y7
)-(x8
, y8
), New
To(centerX
, centerY
)-(x7
, y7
)-(x8
, y8
), 0
s = s + .01
Display
Delay .01
Delay .2
AutoDisplay
Case 10 'The image is divided into stripes in the Y axis, odd go to the right, even go to the left. So the old one is comming out and a new image arrives at the screen. d = Height / 10
XSpd
= Width / 100 'shift speed in X axis is WIDTH/100 pixels per loop Ys(Yf) = (Yf - 1) * d
Xs(s) = Xs(s) - XSpd
PutImage
(Xs
(s
), Ys
(s
)), Old
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) PutImage
(Xs
(s
) + Width, Ys
(s
)), New
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) Xs(s) = Xs(s) + XSpd
PutImage
(Xs
(s
), Ys
(s
)), Old
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) PutImage
(Xs
(s
) - Width, Ys
(s
)), New
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) done = done + XSpd
Display
Delay .01
Delay .02
AutoDisplay
Case 11 'vice versa as Case 10 d = Height / 10
XSpd
= Width / 100 'shift speed in X axis is WIDTH/100 pixels per loop Ys(Yf) = (Yf - 1) * d
Xs(s) = Xs(s) + XSpd
PutImage
(Xs
(s
), Ys
(s
)), Old
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) PutImage
(Xs
(s
) - Width, Ys
(s
)), New
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) Xs(s) = Xs(s) - XSpd
PutImage
(Xs
(s
), Ys
(s
)), Old
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) PutImage
(Xs
(s
) + Width, Ys
(s
)), New
, 0, (0, Ys
(s
))-(Width, Ys
(s
) + d
) done = done + XSpd
Display
Delay .01
Delay .02
AutoDisplay
FreeImage Old
FreeImage New
'is my work for next weekend...
Sub GetImageRatio
(LeftUpperX
, LeftUpperY
, RightDownX
, RightDownY
, handle
) W
= Width(Images
(handle
)) H = Height(Images(handle))
sW
= Width ' Screen Width sH = Height ' Screen Height
RatioX = sW / W
RatioY = sH / H
Ratio = 1 ' if RatioX = RatioY
If RatioX
< RatioY
Then Ratio
= RatioX
If RatioY
< RatioX
Then Ratio
= RatioY
N_I_W = W * Ratio ' New _ Image _ Width
N_I_H = H * Ratio ' New _ Image _ Height
LeftUpperX = (sW - N_I_W) \ 2
RightDownX = sW - LeftUpperX
LeftUpperY = (sH - N_I_H) \ 2
RightDownY = sH - LeftUpperY