condward

blurrytext

Sep 28th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HTML
  2. -------------------------------------------------------------------------------------------------------
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <meta charset="UTF-8">
  7. <title>speedtest</title>
  8.  
  9. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></script>
  10. <script src="https://code.createjs.com/createjs-2015.05.21.min.js"></script>
  11. <script src="https://code.createjs.com/movieclip-0.8.1.min.js"></script>
  12. <script src="speedtest.js"></script>
  13.  
  14. <script>
  15. var canvas, stage, exportRoot;
  16.  
  17. function init() {
  18.     canvas = document.getElementById("canvas");
  19.     images = images||{};
  20.     ss = ss||{};
  21.  
  22.     var loader = new createjs.LoadQueue(false);
  23.     loader.addEventListener("fileload", handleFileLoad);
  24.     loader.addEventListener("complete", handleComplete);
  25. loader.loadFile({src:"images/speedtest_atlas_.json", type:"spritesheet", id:"speedtest_atlas_"}, true);
  26.     loader.loadManifest(lib.properties.manifest);
  27. }
  28.  
  29. function handleFileLoad(evt) {
  30.     if (evt.item.type == "image") { images[evt.item.id] = evt.result; }
  31. }
  32.  
  33. function handleComplete(evt) {
  34.     var queue = evt.target;
  35.     ss["speedtest_atlas_"] = queue.getResult("speedtest_atlas_");
  36.     exportRoot = new lib.speedtest();
  37.  
  38.     stage = new createjs.Stage(canvas);
  39.     stage.addChild(exportRoot);
  40.     stage.update();
  41.  
  42.     createjs.Ticker.setFPS(lib.properties.fps);
  43.     createjs.Ticker.addEventListener("tick", stage);
  44. }
  45. </script>
  46. </head>
  47.  
  48. <body onload="init();" style="background-color:#D4D4D4">
  49.     <canvas id="canvas" width="900" height="600" style="background-color:#FFFFFF"></canvas>
  50. </body>
  51. </html>
  52.  
  53.  
  54. speedtest.js
  55. -------------------------------------------------------------------------------------------------------
  56.  
  57. (function (lib, img, cjs, ss) {
  58.  
  59. var p; // shortcut to reference prototypes
  60.  
  61. // library properties:
  62. lib.properties = {
  63.     width: 550,
  64.     height: 400,
  65.     fps: 24,
  66.     color: "#FFFFFF",
  67.     manifest: []
  68. };
  69.  
  70.  
  71.  
  72. // symbols:
  73.  
  74.  
  75.  
  76. // stage content:
  77. (lib.speedtest = function(mode,startPosition,loop) {
  78.     this.initialize(mode,startPosition,loop,{});
  79.  
  80.     // timeline functions:
  81.     this.frame_0 = function() {
  82.         mytext = new createjs.Text("Lorem ipsum dolor sit amet 2","19px Calibri","#073949");
  83.         mytext.x = 450
  84.         mytext.y = 300;
  85.         stage.addChild(mytext);
  86.        
  87.        
  88.        
  89.        
  90.         resize = function() {
  91.                     var canvas = document.getElementById('canvas');
  92.                     var canvasRatio = canvas.height / canvas.width;
  93.        
  94.                     var windowRatio = window.innerHeight / window.innerWidth;
  95.                     var width;
  96.                     var height;
  97.        
  98.                     if (windowRatio < canvasRatio) {
  99.                         height = window.innerHeight - 35;
  100.                         width = height / canvasRatio;
  101.                     } else {
  102.                         width = window.innerWidth;
  103.                         height = width * canvasRatio;
  104.                     }
  105.                    
  106.                     canvas.style.width = width + 'px';
  107.                     canvas.style.height = height + 'px';   
  108.                    
  109.                    
  110.         }()
  111.     }
  112.  
  113.     // actions tween:
  114.     this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));
  115.  
  116. }).prototype = p = new cjs.MovieClip();
  117. p.nominalBounds = null;
  118.  
  119. })(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
  120. var lib, images, createjs, ss;
Advertisement
Add Comment
Please, Sign In to add comment