REBOL [ Title: "Zoom into Images" Date: 24-April-2001 Version: 0.1.3 File: %zoom-img.r Home: http://www.ross-gill.com/ Author: ["Christopher Ross-Gill" "Renaud GOMBERT"] Rights: "Copyright ©2001 Christopher Ross-Gill" Purpose: "Zoom in to images" History: { 0.1.0 Crude but it works :o) 0.1.1 better user controle + video resizing "on the fly" 0.1.2 controls embeded in video window } Comments: { A fun video-style zoom technique using 'crop and 'fit. Why? Because I can acheive the effect by only loading one image (or two for two examples) and this minimal source code. Also tested is VID magnification for the hi-res monitors. } To-Do: { make the code smarter ;-) avoid video slow down when mouse over image write more generic animation code } ] pause?: false started?: false img: load-image http://www.ross-gill.com/files/castle-flag.jpg img2: load-image http://www.ross-gill.com/files/goatfell-jura.jpg factor: 1 a: layout [ text 120 center bold white "Choose your size" ch: choice 120 "Scale 1:1" "Scale 2:1" "Scale 3:1" [ factor: (to-integer pick ch/text 7) - 48 img-face/size: pnl/pane/size: pnl/size: img-face/size: 240x180 * factor txt/size: 0x40 + (240x5 * factor) txt/font/size: 20 * factor txt/offset/y: 40 * factor a/size: (240x180 * factor) + 180x40 ] btn 120 "PLAY ANIM" [do-anim] bp: button 120 center bold "PAUSE" [ if started? [pause?: not pause?] bp/texts/1: either pause? ["CONTINUE"]["PAUSE"] show bp ] btn 120 "STOP" [ pause?: false started?: false img-face/image: img img-face/effect: [fit] show img-face txt/text: "" show txt bp/texts/1: "PAUSE" show bp ] btn 120 "QUIT" [quit] at 160x20 pnl: box (240x180 * factor) frame black 1x1 ] a/image: load-image http://www.ross-gill.com/r/green.png a/effect: [fit] animate: func [ img frames duration ; in seconds dir ; direction title ; text to show in out /locat waitval ][ img-face/image: img os: 0x0 cp: img/size waitval: duration / frames repeat count frames [ if not started? [exit] either pause? [ count: count - 1 wait 0.01 ][ img-face/effect: compose [crop (os: os + dir) (cp: cp - 2x1) fit] show img-face wait waitval either count = in [ txt/text: title ][ if count = out [txt/text: {}] ] ] ] return cp ] do-anim: does [ pause?: false started?: true bp/texts/1: "PAUSE" show bp animate img 60 3 2x0 "AMS Presents" 1 40 animate img2 60 5 0x0 "The Isle of Arran" 15 40 pause?: false started?: false ] pnl/pane: layout/offset compose [ at 0x0 img-face: image img 240x180 effect [fit] at 0x40 txt: vh1 bold center 240x45 white ] 0x0 view a