doubiantiao4994 2017-01-10 00:56
浏览 123

HTML画布在计算器上的图像CANVAS2IMAGE HTML2CANVAS

Im one of those 'Script Kiddies' just making a Frankenstein'ish HTML PHP JS calculator here on http://tupplefly.com.au/apps/vape_calculator/

I've made the table turn into an image and the user can long press on iOS or right click. But the client wants it to download and unless I use code from here http://greenethumb.com/article/1429/user-friendly-image-saving-from-the-canvas/ the file just downloads as 'untitled' and doesn't open in the appropriate app.

This is what I have so far -

  1. Calculator makes a table for the output - pretty simple. Click the purple image button and it goes into a div as an image.

Calculator

to do that I used these scripts

<button class="button_image" onclick="Submit();" ><i class="fa fa-camera"></i> Image</button>
<div id="img-out" style="width: 100%; margins: 0 auto; text-align: center;"></div>

    <script type="text/javascript" src="canvas2image.js"></script>
<script type="text/javascript" src="html2canvas.js"></script>
  <script type="text/javascript">
    var Submit = function() {
      html2canvas(document.querySelector("#content"), {
        onrendered: function(canvas) {
        var data = canvas.toDataURL('image/png');
        var image = new Image();
        image.src = data;
        document.getElementById('img-out').appendChild(image);
        }
      });
  };
</script>

This is where this next bit here http://greenethumb.com/article/1429/user-friendly-image-saving-from-the-canvas/ comes in. The canvas that has the pretty circles goes into a .png file when the button is clicked. Simple, I needs to get the table onto the canvas, but not simple for me, so when the user clicks the button the canvas of the table is sent to the computer as a .png

    <div id="img-out2" style="width: 100%; margins: 0 auto; text-align: center;">
<canvas id='drawhere_cicles3' width='350' height='350' style="margins: 0 auto; text-align: center; border: 0px solid #ccc"></canvas><br />
<script src='http://greenethumb.com/canvas/circles/circles3.js'></script><br />
<script src='canvassaver.js'></script>
<script>
var cs = new CanvasSaver('saveme.php');
var cnvs = document.getElementById('drawhere_cicles3');
var btn = cs.generateButton('save an image of these pretty circles!', cnvs, 'myimage');
document.getElementById('img-out2').appendChild(btn);
</script></div>

So I need to get the table onto the canvas id='drawhere_cicles3' instead of into the div id content, so when the user clicks the button the canvas is sent to the computer as a .png

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器