<i id='7KNeL'><tr id='7KNeL'><dt id='7KNeL'><q id='7KNeL'><span id='7KNeL'><b id='7KNeL'><form id='7KNeL'><ins id='7KNeL'></ins><ul id='7KNeL'></ul><sub id='7KNeL'></sub></form><legend id='7KNeL'></legend><bdo id='7KNeL'><pre id='7KNeL'><center id='7KNeL'></center></pre></bdo></b><th id='7KNeL'></th></span></q></dt></tr></i><div id='7KNeL'><tfoot id='7KNeL'></tfoot><dl id='7KNeL'><fieldset id='7KNeL'></fieldset></dl></div>

  1. <legend id='7KNeL'><style id='7KNeL'><dir id='7KNeL'><q id='7KNeL'></q></dir></style></legend>

      <bdo id='7KNeL'></bdo><ul id='7KNeL'></ul>
  2. <tfoot id='7KNeL'></tfoot>

    1. <small id='7KNeL'></small><noframes id='7KNeL'>

      如何在 html5 画布中弯曲/弯曲图像

      How to bend/curve a image in html5 canvas(如何在 html5 画布中弯曲/弯曲图像)
      <tfoot id='SEyUq'></tfoot>
    2. <legend id='SEyUq'><style id='SEyUq'><dir id='SEyUq'><q id='SEyUq'></q></dir></style></legend>
      <i id='SEyUq'><tr id='SEyUq'><dt id='SEyUq'><q id='SEyUq'><span id='SEyUq'><b id='SEyUq'><form id='SEyUq'><ins id='SEyUq'></ins><ul id='SEyUq'></ul><sub id='SEyUq'></sub></form><legend id='SEyUq'></legend><bdo id='SEyUq'><pre id='SEyUq'><center id='SEyUq'></center></pre></bdo></b><th id='SEyUq'></th></span></q></dt></tr></i><div id='SEyUq'><tfoot id='SEyUq'></tfoot><dl id='SEyUq'><fieldset id='SEyUq'></fieldset></dl></div>

              • <bdo id='SEyUq'></bdo><ul id='SEyUq'></ul>

                <small id='SEyUq'></small><noframes id='SEyUq'>

                  <tbody id='SEyUq'></tbody>
                本文介绍了如何在 html5 画布中弯曲/弯曲图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有这个

                我想这样做

                HTML

                <canvas id="mycanvas"></canvas>
                

                JS

                var temp_can1, temp_can1_ctx;
                $(document).ready(function () {
                temp_can1 = document.getElementById('mycanvas');
                temp_can1_ctx = temp_can1.getContext('2d');
                var imageObj_rotator3 = new Image();
                
                imageObj_rotator3.onload = function () {
                
                    temp_can1_ctx.drawImage(imageObj_rotator3, 0, 0);
                    temp_can1_ctx.globalCompositeOperation = "source-atop";
                    var pattern = temp_can1_ctx.createPattern(imageObj_rotator3, 'no-repeat');
                    temp_can1_ctx.rect(0, 0, temp_can1.width, temp_can1.height);
                    temp_can1_ctx.fillStyle = pattern;
                    temp_can1_ctx.fill();
                    temp_can1_ctx.globalAlpha = 0.10;
                    temp_can1_ctx.drawImage(imageObj_rotator3, 0, 0);
                    temp_can1_ctx.drawImage(imageObj_rotator3, 0, 0);
                    temp_can1_ctx.drawImage(imageObj_rotator3, 0, 0);
                
                };
                imageObj_rotator3.src = 'http://i.stack.imgur.com/o8EJp.png';
                
                });
                

                这是我的 JSFiddler更新的 JSFiddler

                这可以在 html5 画布中实现吗?如果可能的话,请告诉我一些方向/示例.

                is this possible to do in html5 canvas. if possible then show me some direction/example.

                谢谢

                推荐答案

                不可能使用任何原生 Canvas 转换,因为您的拉伸输出需要 非仿射 转换.即它不能简单地通过组合旋转、平移等来实现.

                It's not possible using any native Canvas transformations as your stretched output requires non-affine transformations. i.e. it cannot be achieved simply by combining rotations, translations, etc.

                理想情况下,您需要定义一个公式映射到扭曲坐标系中的原始笛卡尔坐标,然后迭代目标像素空间,使用上述映射确定该像素所需的颜色.

                Ideally you need to define a formula mapping to the original cartesian coordinates from the distorted coordinate system and then iterate over the destination pixel space, using the above mapping to determine the required colour for that pixel.

                您还需要插入相邻像素以避免输出看起来块状".

                You would also need to interpolate neighbouring pixels to avoid the output looking "blocky".

                这很重要……

                这篇关于如何在 html5 画布中弯曲/弯曲图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to make rooftext effect and valley text effect in HTML5 (or Fabric.js)(如何在 HTML5(或 Fabric.js)中制作屋顶文字效果和山谷文字效果)
                Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)
                How to upload image into HTML5 canvas(如何将图像上传到 HTML5 画布中)
                <i id='u18fl'><tr id='u18fl'><dt id='u18fl'><q id='u18fl'><span id='u18fl'><b id='u18fl'><form id='u18fl'><ins id='u18fl'></ins><ul id='u18fl'></ul><sub id='u18fl'></sub></form><legend id='u18fl'></legend><bdo id='u18fl'><pre id='u18fl'><center id='u18fl'></center></pre></bdo></b><th id='u18fl'></th></span></q></dt></tr></i><div id='u18fl'><tfoot id='u18fl'></tfoot><dl id='u18fl'><fieldset id='u18fl'></fieldset></dl></div>
                    <tbody id='u18fl'></tbody>

                  <small id='u18fl'></small><noframes id='u18fl'>

                  <legend id='u18fl'><style id='u18fl'><dir id='u18fl'><q id='u18fl'></q></dir></style></legend>
                  • <bdo id='u18fl'></bdo><ul id='u18fl'></ul>

                      <tfoot id='u18fl'></tfoot>