Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
5.3 KiB

  1. // ActiveVRML 1.0 ASCII
  2. /*****************************************************************************\
  3. *
  4. * Library code
  5. *
  6. \*****************************************************************************/
  7. model = let
  8. createBitmap(image, xSize, ySize) = (image, point2Xy(xSize, ySize));
  9. imageOf(image, size : point2) = image;
  10. sizeOf(image, size : point2) = size;
  11. xsizeOf(image, size : point2) = xComponent(size);
  12. ysizeOf(image, size : point2) = yComponent(size);
  13. accumulate(func, value, lst) =
  14. if empty(lst) then
  15. value
  16. else
  17. accumulate(func, func(head(lst), value), tail(lst));
  18. after(endTime) = predicate(time > endTime);
  19. interpolate(from : number, to : number, num : number) =
  20. from + (to - from) * num;
  21. interpolateVector2(from : vector2, to : vector2, num) =
  22. vector2Xy
  23. (
  24. interpolate(xComponent(from), xComponent(to), num),
  25. interpolate(yComponent(from), yComponent(to), num)
  26. );
  27. smooth0to1 = (0.5 - cos (time * pi) / 2) until after(1) => end;
  28. in let
  29. /*****************************************************************************\
  30. *
  31. * The background
  32. *
  33. \*****************************************************************************/
  34. backBitmap = import("back.gif");
  35. backImage = imageOf(backBitmap);
  36. backXSize = xsizeOf(backBitmap);
  37. backYSize = ysizeOf(backBitmap);
  38. /*****************************************************************************\
  39. *
  40. * Blinking stars on the background
  41. *
  42. \*****************************************************************************/
  43. brightBitmap = import("bright.bmp");
  44. dimBitmap = import("dim.bmp");
  45. starImage =
  46. let
  47. s0 = imageOf(dimBitmap) until after(1) => function x. s1;
  48. s1 = imageOf(brightBitmap) until after(0.25) => function x. s0;
  49. in
  50. s0;
  51. /*****************************************************************************\
  52. *
  53. * The title letters
  54. *
  55. \*****************************************************************************/
  56. titleImage =
  57. let
  58. titlePos = vector2Xy(-0.60 * backXSize, 0.9 * backYSize);
  59. images =
  60. [
  61. first(import("title0.gif")),
  62. first(import("title1.gif")),
  63. first(import("title2.gif")),
  64. first(import("title3.gif")),
  65. first(import("title4.gif")),
  66. first(import("title5.gif")),
  67. first(import("title6.gif")),
  68. first(import("title7.gif")),
  69. first(import("title8.gif")),
  70. first(import("title9.gif"))
  71. ];
  72. zoomImage =
  73. let
  74. number = smooth0to1;
  75. in
  76. transformImage(
  77. translate(titlePos * number)
  78. o scale2(number),
  79. nth(images, 0)
  80. );
  81. glowImage =
  82. let
  83. index = sin(time * 2 - pi / 2) * 4.99 + 5;
  84. in
  85. nth(images, index);
  86. image =
  87. emptyImage until after(1) => function(x) .
  88. zoomImage until done => function(x) .
  89. transformImage(
  90. translate(titlePos),
  91. glowImage
  92. );
  93. in
  94. image;
  95. /*
  96. zoomInTransform
  97. */
  98. /*****************************************************************************\
  99. *
  100. * Button swoosh animation
  101. *
  102. \*****************************************************************************/
  103. swooshImage(motionImage, staticImage, xsize, xend, yend, delay) =
  104. let
  105. number = time * 4;
  106. maxSize = (backXSize + xend + xsize) / 2;
  107. midPoint = (-backXSize + xend + xsize) / 2;
  108. stretchIn(number) =
  109. transformImage(
  110. translate(
  111. interpolate(-backXSize, midPoint, number),
  112. yend
  113. )
  114. o scale(number * maxSize / xsize, 1),
  115. motionImage
  116. );
  117. shrinkIn(number) =
  118. transformImage(
  119. translate(
  120. interpolate(midPoint, xend, number),
  121. yend
  122. )
  123. o scale(
  124. interpolate(maxSize / xsize, 1, number), 1
  125. ),
  126. motionImage
  127. );
  128. static =
  129. transformImage(
  130. translate(xend, yend),
  131. staticImage
  132. );
  133. image =
  134. if (number < 1) then
  135. stretchIn(number)
  136. else if (number < 2) then
  137. shrinkIn(number - 1)
  138. else
  139. static;
  140. sound = first(import("schwoop.wav"));
  141. in
  142. (emptyImage, silence) until after(delay) => function(x) .
  143. (image, sound);
  144. /*****************************************************************************\
  145. *
  146. * The buttons
  147. *
  148. \*****************************************************************************/
  149. tutorialBitmap = import("tbutton.bmp");
  150. (tutorialImage, tutorialSound) =
  151. swooshImage(
  152. first(import("tutor.gif")),
  153. first(import("tutor.gif")),
  154. xComponent(second(import("tutor.gif"))),
  155. 0,
  156. 0,
  157. 3
  158. );
  159. modelSound = tutorialSound;
  160. //
  161. // put it all together
  162. //
  163. modelImage =
  164. titleImage
  165. over tutorialImage
  166. over backImage;
  167. model = (modelImage, modelSound, modelSound)
  168. until leftButtonDown => function(x) . model;
  169. in model;