package heroes; import f3.ui.*; import f3.ui.canvas.*; import java.lang.System; class Heroes extends CompositeNode { attribute ticketX: Number; attribute ticketY: Number; attribute ticketVisible: Boolean; attribute ticketOpacity: Number; attribute ticketScale: Number; attribute ticketRotation: Number; attribute bookX: Number; attribute bookY: Number; attribute bookVisible: Boolean; attribute bookOpacity: Number; attribute bookScale: Number; attribute bookRotation: Number; attribute pictureX: Number; attribute pictureY: Number; attribute pictureVisible: Boolean; attribute pictureOpacity: Number; attribute pictureScale: Number; attribute pictureRotation: Number; attribute degreeX: Number; attribute degreeY: Number; attribute degreeVisible: Boolean; attribute degreeOpacity: Number; attribute degreeScale: Number; attribute degreeRotation: Number; attribute tvX: Number; attribute tvY: Number; attribute tvVisible: Boolean; attribute tvHover: Boolean; attribute tvOpacity: Number; attribute tvScale: Number; attribute tvRotation: Number; attribute selectedImageOpacity: Number; attribute selectedImageIndex: Number; attribute photoUrls: String*; attribute thumbUrls: String*; } attribute Heroes.selectedImageOpacity = 1; trigger on Heroes.selectedImageIndex = value { selectedImageOpacity = [0,.01..1] dur 500 while selectedImageIndex == value; } attribute Heroes.thumbUrls = foreach (i in [1..10]) "http://www.nbc.com/Heroes/cast/gallery_thumbs/professor0{i format as <<00>>}.jpg"; attribute Heroes.photoUrls = foreach (i in [1..10]) "http://www.nbc.com/Heroes/cast/gallery_photos/professor0{i format as <<00>>}.jpg"; attribute Heroes.ticketRotation = -90; attribute Heroes.ticketScale = 0.04; attribute Heroes.ticketOpacity = 0.0; attribute Heroes.ticketX = 655; attribute Heroes.ticketY = 230; attribute Heroes.bookRotation = -10; attribute Heroes.bookScale = 0.01; attribute Heroes.bookOpacity = 0.0; attribute Heroes.bookX = 140; attribute Heroes.bookY = 220; attribute Heroes.pictureRotation = -10; attribute Heroes.pictureScale = 0.01; attribute Heroes.pictureOpacity = 0.0; attribute Heroes.pictureX = 140; attribute Heroes.pictureY = 220; attribute Heroes.degreeRotation = -10; attribute Heroes.degreeScale = 0.01; attribute Heroes.degreeOpacity = 0.0; attribute Heroes.degreeX = 140; attribute Heroes.degreeY = 220; attribute Heroes.tvRotation = -10; attribute Heroes.tvScale = 0.01; attribute Heroes.tvOpacity = 0.0; attribute Heroes.tvX = 140; attribute Heroes.tvY = 220; trigger on Heroes.bookVisible = value { if (value) { for (unitinterval r in dur 500 fps 100) { //bookX = (r * 140) bookY = 420 + (r * -200); bookOpacity = r; bookScale = (0.8 * r); bookRotation = -10 + (10 * r); } } else { for (unitinterval i in dur 500 fps 100) { var r = 1-i; //bookX = (r * 140); bookY = 420 +(r * -200); bookOpacity = r; bookScale = (0.8 * r); bookRotation = -10 + (10 * r); } } } trigger on Heroes.ticketVisible = value { if (value) { for (unitinterval r in dur 500 fps 50) { ticketX = 655 - (r * 455); ticketY = 230 - (r * 100); ticketOpacity = r; ticketScale = 0.04 + (0.96 * r); ticketRotation = -90 + (90 * r); } } else { for (unitinterval i in dur 500 fps 50) { var r = 1-i; ticketX = 655 - (r * 455); ticketY = 230 - (r * 100); ticketOpacity = r; ticketScale = 0.04 + (0.96 * r); ticketRotation = -90 + (90 * r); } } } trigger on Heroes.pictureVisible = value { if (value) { for (unitinterval r in dur 500 fps 50 while pictureVisible == value) { pictureX = 350 + r * -30; pictureY = 190 + r * -30; pictureOpacity = r; pictureScale = 0.04 + (0.96 * r); pictureRotation = -10 + (10 * r); } } else { for (unitinterval i in dur 500 fps 50 while pictureVisible == value) { var r = 1-i; pictureX = 350 + r * -30; pictureY = 190 + r * -30; pictureOpacity = r; pictureScale = 0.04 + (0.96 * r); pictureRotation = -10 + (10 * r); } } } trigger on Heroes.degreeVisible = value { if (value) { for (unitinterval r in dur 500 fps 50) { degreeX = 355 + (r*-50); degreeY = 232 + r * -50; degreeOpacity = r; degreeScale = 0.04 + (0.96 * r); degreeRotation = -10 + (10 * r); } } else { for (unitinterval i in dur 500 fps 50) { var r = 1-i; degreeX = 355 + (r * -50); degreeY = 232 + (r * -50); degreeOpacity = r; degreeScale = 0.04 + (0.96 * r); degreeRotation = -10 + (10 * r); } } } trigger on Heroes.tvVisible = value { tvScale = 1; tvOpacity = 1; tvRotation = 0; tvX = 600; if (value) { for (unitinterval r in dur 500 fps 50) { tvY = 700 - (r * 530); } } else { for (unitinterval i in dur 500 fps 50) { var r = 1-i; tvY = 700 - (r * 530); } } } function Heroes.composeNode() = Clip { var font = Font {face: {url: "{__DIR__}/augie.ttf"}, style: ITALIC size: 10} shape: Rect { height: 550, width: 1100} content: [ImageView { // Main Background image: {url: "{__DIR__}/images/3.jpg"} }, ImageView { // Unopened Notebook cursor: HAND transform: translate(50, 375) image: {url: "{__DIR__}/images/6.png"} onMouseClicked: operation(e) {bookVisible = true;} }, Rect { // Mouse handler for minimized plane ticket var: rect cursor: HAND transform: translate(655, 220) height: 20 width: 10 fill: bind new Color(1, 1, 1, if rect.hover then 0.1 else 0) onMouseClicked: operation(e) { ticketVisible = not ticketVisible; } }, ImageView { // Expanded plane ticket cursor: HAND opacity: bind ticketOpacity transform: bind [translate(ticketX, ticketY), rotate(ticketRotation, 0, 0), scale(ticketScale, ticketScale)] image: {url: "{__DIR__}/images/10.png"} onMouseClicked: operation(e) { ticketVisible = not ticketVisible; } }, ImageView { // Mohinder image transform: translate(660, 50) image: {url: "{__DIR__}/images/4.png"} }, Rect { // Mouse handler for minimized picture var: rect fill: bind new Color(1, 1, 1, if rect.hover then 0.1 else 0) cursor: HAND height: 35 width: 30 arcHeight: 5 arcWidth: 5 onMouseClicked: operation(e) { pictureVisible = not pictureVisible; } transform: [translate(350, 190), skew(0, 10)] }, ImageView { // Expanded Picture cursor: HAND opacity: bind pictureOpacity transform: bind [translate(pictureX, pictureY), rotate(pictureRotation, 0, 0), scale(pictureScale, pictureScale)] image: {url: "{__DIR__}/images/8.png"} onMouseClicked: operation(e) { pictureVisible = not pictureVisible; } }, Rect { // Mouse handler for minimized degree cursor: HAND height: 20 width: 21 var: rect fill: bind new Color(1, 1, 1, if rect.hover then 0.1 else 0) arcHeight: 5 arcWidth: 5 onMouseClicked: operation(e) { degreeVisible = not degreeVisible; } transform: [translate(355, 232), skew(0, -4)] }, ImageView { // Expanded Degree cursor: HAND opacity: bind degreeOpacity transform: bind [translate(degreeX, degreeY), rotate(degreeRotation, 0, 0), scale(degreeScale, degreeScale)] image: {url: "{__DIR__}/images/9.png"} onMouseClicked: operation(e) { degreeVisible = not degreeVisible; } }, Rect { // Mouse handler for minimized TV cursor: HAND onMouseClicked: operation(e) {tvVisible = not tvVisible;} hover: bind tvHover fill: bind new Color(1, 1, 1, if tvHover then 0.1 else 0) arcHeight: 5 arcWidth: 5 height: 33 width: 37 transform: translate(435, 266) }, Clip { // White noise on TV visible: bind tvHover transform: [translate(437, 268), skew(0, -4)] shape: Rect { arcHeight: 10 arcWidth: 10 height: 33 width: 36 } content: ImageView { transform: bind [translate(-10, -10), rotate(if tvHover then [0..360] dur 300 linear continue if true else 0, 30, 30)] selectable: false image: {url: "{__DIR__}/images/5.jpg"} } }, ImageView { // Expanded TV cursor: HAND opacity: bind tvOpacity halign: CENTER transform: bind [translate(tvX, tvY), rotate(tvRotation, 0, 0), scale(tvScale, tvScale)] image: {url: "{__DIR__}/images/7.png"} onMouseClicked: operation(e) { tvVisible = not tvVisible; } }, Group { // Expanded Notebook opacity: bind bookOpacity transform: bind [translate(bookX, bookY), rotate(bookRotation, 0, 0), scale(bookScale, bookScale)] content: [ImageView { // Notebook background image cursor: HAND image: {url: "{__DIR__}/images/2.png"} }, Group { // Slide show opacity: bind selectedImageOpacity transform: bind translate(60, 150) //halign: CENTER valign: CENTER content: bind [select Group { var im = ImageView { // Selected Photo transform: [scale(0.34, 0.34)] image: {url: u} }, content: [Rect { // White background visible: bind im.loaded transform: translate(-5, -5) fill: white height: bind im.currentHeight + 10 width: bind im.currentWidth + 10 }, Text { visible: bind not im.loaded font: new Font{ face: font.face, style: BOLD, size: 12} content: "LOADING . . ." transform: bind translate(30, 30) }, im, Group { // Photo holder corners visible: bind im.loaded content: [ImageView { // NW corner transform: [translate(im.currentX, im.currentY), rotate(180, 0, 0)] valign: CENTER halign: CENTER image: {url: "{__DIR__}/images/1.png"} }, ImageView { // NE corner transform: [translate(im.currentX+im.currentWidth, im.currentY), rotate(-90, 0, 0)] valign: CENTER halign: CENTER image: {url: "{__DIR__}/images/1.png"} }, ImageView { // SE corner transform: [translate(im.currentX+im.currentWidth, im.currentY+im.currentHeight), rotate(0, 0, 0)] valign: CENTER halign: CENTER image: {url: "{__DIR__}/images/1.png"} }, ImageView { // SW corner transform: [translate(im.currentX, im.currentY+im.currentHeight), rotate(90, 0, 0)] valign: CENTER halign: CENTER image: {url: "{__DIR__}/images/1.png"} }] }] } from u in photoUrls[selectedImageIndex]] }, Group { // Thumbnail Slides transform: [translate(60, 315), scale(0.5, 0.5), rotate(0, 0, 0), ] visible: true content: VBox { content: [HBox { // Row 1 content: foreach (i in [0..4]) Group { transform: translate(10, 0) content: [Rect {height: 50, width: 50, fill: white}, ImageView { onMouseClicked: operation(e) {selectedImageIndex = i;} clip: {shape: Rect {height: 40, width: 40}} transform: translate(5, 5) image: {url: bind thumbUrls[i]} }] } }, HBox { // Row 2 transform: translate(0, 10) content: foreach (i in [5..9]) Group { transform: translate(10, 0) content: [Rect {height: 50, width: 50, fill: white}, ImageView { onMouseClicked: operation(e) {selectedImageIndex = i;} clip: {shape: Rect {height: 40, width: 40}} transform: translate(5, 5) image: {url: bind thumbUrls[i]} }] } }] } }, Text { font: font transform: [translate(270, 60), rotate(-2, 0, 0)] content: "PROFESSOR MOHINDER SURESH A tenured genetics professor at the University of Madras. His father Chandra was also a professor until he disappeared from India and the accredited academic world years ago after raving about a \"global event\" that would change mankind. He thought his answers would be in New York. Three days ago, Chandra was murdered. Mohinder moves to New York, hoping to find out why his father was killed. This begins with unconvering what his father was working on. But somone else is after his father's work as well... " }] onMouseClicked: operation(e) { bookVisible = not bookVisible; } }, ] }; Frame { var: frame onClose: operation() {System.exit(0);} visible: true title: "Heroes" content: Canvas { cursor: DEFAULT background: black content: Heroes { var scaleValue = bind frame.width/1100 transform: bind scale(scaleValue, scaleValue) opacity: bind if frame.showing then [0,0.1..1] dur 1000 else 0 } } }