Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: HTML  |  size: 3.07 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. <!DOCTYPE HTML>
  3. <!------------------------------------------------------------------------------
  4. Copyright (c) 2011 Antoine Santo Aka NoNameNo
  5.  
  6. This File is part of the CODEF project. (http://code.google.com/p/codef/)
  7.  
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14.  
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17.  
  18. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. THE SOFTWARE.
  25. ------------------------------------------------------------------------------>
  26. <!------------------------------------------------------------------------------
  27.  
  28. FILE : 04_core
  29.  
  30. In this tutorial you can see how to load a image and display it using this :
  31.                 myimage=new image('logo.png');
  32.  
  33. this function will load your image and return a object with function draw :
  34.         .draw(dst,posx,posy) = a nice function to draw your image a the dst canvas
  35.  
  36. ------------------------------------------------------------------------------>
  37. <html>
  38. <head>
  39.  
  40. <script src="http://codef.santo.fr/codef/codef_core.js"></script>
  41. <script>
  42.  
  43. var myorder= new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','!','.',':',',','-','6','0','5','(',')',' ');
  44.  
  45. var myimage=new image('1.png');
  46. var mycanvas;
  47. var space;
  48.  
  49. var fontw=48;
  50. var fonth=103;
  51. var nbx=10;
  52. var nby=6;
  53.  
  54. function init(){
  55.         mycanvas=new canvas(fontw*nbx,fonth*nby,"main");
  56.         myimage.initTile(fontw,fonth,65);
  57.         space=findit(32);
  58.        
  59.         go();
  60. }
  61.  
  62. function print(x,y,char){
  63.         myimage.drawTile(mycanvas,char,x,y);
  64. }
  65.  
  66. function findit(char){
  67.         var found=-1;
  68.         for(i=0; i<myorder.length;i++){
  69.                 if(myorder[i].charCodeAt(0)==char)
  70.                         found=i;
  71.         }
  72.         if(found==-1)
  73.                 found=space;
  74.         return found;
  75. }
  76.  
  77. function go(){
  78.         count=32;
  79.         mycanvas.clear();
  80.  
  81. for(y=0;y<nby;y++){
  82. for(x=0;x<nbx;x++){
  83.         var char=count++;
  84.         print(x*fontw,y*fonth,findit(char));
  85. }
  86. }
  87.  
  88.        
  89.  
  90.  
  91.  
  92.  
  93.         requestAnimFrame( go );
  94. }
  95.  
  96. </script>
  97. </head>
  98. <body onLoad="init();" bgcolor="#000000">
  99. <br>
  100. <br>
  101. <center><div id="main"></div><br>
  102. <img src="1.png">
  103. <br><a href="javascript:window.location='view-source:'+window.location">View Source</a><br><br>
  104. <b>04_core</b> is part of the <a href="http://code.google.com/p/codef/">CODEF</a> project.</center>
  105. </body>
  106. </html>