html Meme Maker的入门代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Meme Maker的入门代码相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>

<html>
<head>
  <title>MemeMaker-Simple</title>
    
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <style>
    #image-container {
      display: flex;
    }
  </style>
</head>

<body>

  <div>
    <input type="file" id="file" />  
  </div>
  <div id="image-container">
    <canvas width="500" height="500"></canvas>
    <div>
      <span>Top Line:</span><br/>
      <input id="topLineText" type="text"><br/>
      <span>Bottom Line:</span><br/>
      <input id="bottomLineText" type="text"><br/>
      <button id="saveBtn">Save</button>
    </div>
  </div>
  <script>
    function textChangeListener (evt) {
      var id = evt.target.id;
      var text = evt.target.value;
      
      if (id == "topLineText") {
        window.topLineText = text;
      } else {
        window.bottomLineText = text;
      }
      
      redrawMeme(window.imageSrc, window.topLineText, window.bottomLineText);
    }
    
    function redrawMeme(image, topLine, bottomLine) {
      // Get Canvas2DContext
      var canvas = document.querySelector('canvas');
      var ctx = canvas.getContext("2d");
      // Your code here
    }
    
    function saveFile() {
      window.open(document.querySelector('canvas').toDataURL());
    }
    

    function handleFileSelect(evt) {
      var canvasWidth = 500;
      var canvasHeight = 500;
      var file = evt.target.files[0];
      
      
      
      var reader = new FileReader();
      reader.onload = function(fileObject) {
        var data = fileObject.target.result;
        
        // Create an image object
        var image = new Image();
        image.onload = function() {
          
          window.imageSrc = this;
          redrawMeme(window.imageSrc, null, null);
        }
        
        // Set image data to background image.
        image.src = data;
        console.log(fileObject.target.result);
      };
      reader.readAsDataURL(file)
    }
    
    window.topLineText = "";
    window.bottomLineText = "";
    var input1 = document.getElementById('topLineText');
    var input2 = document.getElementById('bottomLineText');
    input1.oninput = textChangeListener;
    input2.oninput = textChangeListener;
    document.getElementById('file').addEventListener('change', handleFileSelect, false);
    document.querySelector('button').addEventListener('click', saveFile, false);
  </script>

</body>
</html>

以上是关于html Meme Maker的入门代码的主要内容,如果未能解决你的问题,请参考以下文章

RPG MAKER MV 打包APK教程(一键打包,无需编写任何代码)

调用百度地图 API 移动地图时 maker 始终在地图中间 并根据maker 经纬度 返回地址

UiWebView 上的 Meme 类型错误

synopsys license maker

C. Meme Problem

无法转换类型“Meme!”的值到预期的参数类型'@noescape (Meme) throws -> Bool'