Here the source code:
REBOL [
Title: "Scrolling Movie Credits"
Date: 16-May-2001
Version: 1.0.1
File: %credits.r
Author: "Carl Sassenrath"
Purpose: {Displays scrolling credits over an image. (Most of this example is the text for the credits.)
}
]
pic: load-thru/binary http://www.rebol.com/view/bay.jpg
roller: layout [
backdrop pic effect [multiply 60.20.30 fit]
text center bold 240x30 "REBOL, The Movie" yellow font [size: 16]
credits: text white bold center 240x180 rate 30 para [origin: 0x+100]
feel [engage: func [f a e] [
if a = 'time [f/para/origin: f/para/origin - 0x1 show f]
]
] ]
credits/text: { Edit This File To Add Your Own Credits It is very simple to do. Only takes a minute. Only REBOL Makes It Possible... }
view roller
Here is my modification of the script:
ReplyDeleteREBOL [
Title: "Scrolling Movie Credits"
Date: 16-May-2001
Version: 1.0.1
File: %credits.r
Author: "Carl Sassenrath, Bohdan Lechnowsky"
Purpose: {Displays scrolling credits over an image. (Most of
this example is the text for the credits.)
}
]
screensize: system/view/screen-face/size
pic-of-day: has [pic][
if error? try [pic: join bdsite: http://apod.nasa.gov/apod/ copy/part a: find/tail rbdsite: read bdsite to-string #{3C696D67207372633D22} find a {"}][
pic: 0.0.0
]
desc: copy/part mark: find/tail a "Explanation:" find mark "Tomorrow's picture"
replace/all desc "^/" " "
while [find desc " "][replace/all desc " " " "]
replace/all desc form to-tag 'p "^/^/"
replace/all desc form to-tag 'br "^/"
replace/all desc form to-tag "br/" "^/"
replace/all desc form to-tag "br /" "^/"
while [find desc "<"][remove/part mark: find desc "<" find/tail mark ">"]
pic
]
img-of-day: has[img i t l][
if error? try [img: load pic-of-day][
layout [i: box 0.0.0 1x1]
img: to-image i
desc: copy ""
]
layout compose [
t: text as-is (desc) bold white black (screensize/x / 4) right
]
l: layout/origin/offset compose [
i: box (img) (screensize - 0x20)
at (screensize - 50x50 - t/size)
image (to-image t) effect [key 0.0.0 shadow 0.0.0]
] 0x0 0x0
to-image l
]
roller: layout/offset [
backdrop img-of-day effect [aspect]
text center bold screensize/x "REBOL, The Movie" yellow font-size 48
credits: text white bold center screensize rate 60 font-size 32 para [origin: screensize * 0x1]
feel [engage: func [f a e] [
if a = 'time [
f/para/origin/y: f/para/origin/y - (d: to-decimal now/time/precise - tm * 40)
if d >= 1 [tm: now/time/precise]
show f
]
]
]
] 0x0
credits/text: {
This modification of Carl Sassenrath's
"Roller" script downloads the Astronomy
Image of the Day from apod.nasa.gov,
parses the description of the image
from that site, and overlays it on the
bottom-right corner of the picture.
Then, the explanation you are now reading
is scrolled over the background picture
at a speed of 40 pixels/second on any
speed CPU.
Only REBOL Makes It Possible...
}
tm: now/time/precise
view roller
Your style is obfuscated and your parsing rules are not correct, try this:
Deletetemp: read http://apod.nasa.gov/apod/
parse temp [thru {<img src="} copy temp2 to {"} to end]
pic: load join http://apod.nasa.gov/apod/ temp2
parse temp [ thru "Explanation:" copy temp2 to "Tomorrow's picture" to end]
desc: form (remove-each tag (load/markup temp2) [tag? tag])
roller: layout [
backdrop pic effect [ fit]
text center bold 240x30 "REBOL, The Movie" yellow font [size: 16]
credits: vtext white bold center 240x180 rate 30 para [origin: 0x+100]
feel [engage: func [f a e] [
if a = 'time [f/para/origin: f/para/origin - 0x1 show f]
]
]
]
credits/text: join desc {
This modification of the modification of Carl Sassenrath's
"Roller" script downloads the Astronomy
Image of the Day from apod.nasa.gov,
parses the description of the image
from that site, and overlays it on this scroller text.
Only REBOL Makes It Possible...
}
view roller
I like your style.
ReplyDeleteHere with loop of the text:
ReplyDeleteRebol[]
temp: read http://apod.nasa.gov/apod/
parse temp [thru {<img src="} copy temp2 to {"} to end]
pic: load join http://apod.nasa.gov/apod/ temp2
parse temp [ thru "Explanation:" copy temp2 to "Tomorrow's picture" to end]
desc: form (remove-each tag (load/markup temp2) [tag? tag])
roller: layout [
backdrop pic effect [ fit]
text center bold 240x30 "REBOL, The Movie" yellow font [size: 16]
credits: vtext white bold center 240x180 rate 30 para [origin: 0x+100]
feel [engage: func [f a e] [
if a = 'time [
f/para/origin: f/para/origin - 0x1 show f
print [f/para/origin/2 max_v]
if f/para/origin/2 < max_v [ f/para/origin: 0x100 ]
]
]
]
]
credits/text: join desc {
This is the modification of the modification of Carl Sassenrath's
"Roller" script. It downloads the Astronomy
Image of the Day from apod.nasa.gov,
parses the description of the image
from that site, and overlays it on this scroller text.
Only REBOL Makes It Possible...
}
;aprroximately with font 12x12 this formula calculates the height of the credits text in a box lenght 240
max_v: ( length? credits/text) * 12 / 240 * 12
max_v: 0 - max_v
view roller
This comment has been removed by the author.
ReplyDeleteActually, other than the improved parse rules and your clever use of 'remove-each, my script was exactly the way I wanted it. I've integrated your mods and then added an automatic line-break routine and written a loop procedure that doesn't need to guess at how high the credit text is.
ReplyDeleteBehold:
REBOL [
Title: "Scrolling Movie Credits"
Date: 16-May-2001
Version: 1.0.1
File: %credits.r
Author: "Carl Sassenrath, Bohdan Lechnowsky, Anger Angel"
Purpose: {Displays scrolling credits over an image. Added error checking, dynamic image loading from the web, dynamic image composition, dynamic text loading from the web, automatic looping, automatic line breaking, and scroll speed auditing.}
Notes: {Thanks to Anger Angel for some cool coding enhancements.}
]
screensize: system/view/screen-face/size
pic-of-day: has [pic][
if error? try [
bdsite: read http://apod.nasa.gov/apod/
parse bdsite [thru {<img src="} copy a to {"} to end]
pic: load join http://apod.nasa.gov/apod/ a
][
pic: 0.0.0
]
parse bdsite [thru "Explanation:" copy a to "Tomorrow's picture" to end]
replace/all a {^/} { }
desc: form remove-each tag load/markup a [tag? tag]
while [find desc #{2020}][replace/all desc #{2020} { }]
pic
]
img-of-day: has[img i t l][
if error? try [img: pic-of-day][
layout [i: box 0.0.0 1x1]
img: to-image i
desc: copy ""
]
layout compose [
t: text as-is (desc) bold white black (screensize/x / 4) right
]
l: layout/origin/offset compose [
i: box (img) (screensize - 0x20)
at (screensize - 50x50 - t/size)
image (to-image t) effect [key 0.0.0 shadow 0.0.0]
] 0x0 0x0
to-image l
]
roller: layout/offset [
backdrop img-of-day effect [aspect]
text center bold screensize/x "REBOL, The Movie" yellow font-size 48
credits: text sky bold center screensize rate 60 font-size 32 para [origin: screensize * 0x1]
feel [engage: func [f a e] [
if a = 'time [
f/para/origin/y: f/para/origin/y - (d: to-decimal now/time/precise - tm * 40)
if d >= 1 [tm: now/time/precise]
show f
if f/para/origin/y + f/size/y < -100 [
f/para/origin/y: screensize/y
tm: now/time/precise
]
]
]
]
] 0x0
insert desc {This modification of Carl Sassenrath's "Roller" script downloads the Astronomy Image of the Day from apod.nasa.gov, parses the description of the image from that site, and overlays it on the bottom-right corner of the picture. Then, the explanation you are now reading is scrolled over the background picture at a speed of 40 pixels/second on any speed CPU.
Only REBOL makes it this easy...
-----
}
forever [change desc: any [find skip desc 40 " " do [desc: head desc break]] "^/"]
credits/text: head desc
tm: now/time/precise
view roller