display.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. (function () {
  2. var state = $.state();
  3. // create canvas and add to document
  4. var canvas = state.canvas;
  5. document.body.insertBefore(canvas, document.body.firstChild);
  6. document.body.style.margin = 0;
  7. canvas.style.width = '100%';
  8. canvas.style.height = '100%';
  9. $.resize();
  10. // add font css and draw text
  11. $.state.put("css", $.util.insertCss(""))
  12. console.log($.state.css())
  13. //var text = document.createElement('div')
  14. //text.innerText = "the quick brown fox jumps over the lazy dog"
  15. //text.style.position = 'absolute';
  16. //text.style.top = "23%"
  17. //text.style.fontSize = '42px'
  18. //text.style.fontFamily = 'blackcasperregular'
  19. //document.body.insertBefore(text, canvas)
  20. // resize canvas on window resize, but not too often
  21. $.util.throttle("resize", "optimizedResize")
  22. window.addEventListener('optimizedResize', function () { $.resize(); })
  23. // load image and start rendering
  24. var img = document.createElement('img')
  25. img.src = state.src;
  26. $.state.put("img", img)
  27. // start rendering
  28. $.start()
  29. })