我有一个 div,它获取用户图像并将用户文本放在上面。我的目标是让用户在看到预览并根据自己的喜好自定义图像/文本后,能够通过单击按钮来下载或保存图像。这可能吗?这是我的代码:(我是 html/css 新手,所以请原谅丑陋的格式/方法)
HTML:
<script `src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>`
<p>DOM-rendered</p>
<p> </p>
<div id="imagewrap" class="wrap" style="border-style: solid;">
<img src="../images/environment.gif" id="img_prev" width="640" height="640" />
<h3 class="desc">Something Inspirational</h3>
</div>
<div id="canvasWrapper" class="outer">
<p>Canvas-rendered (try right-click, save image as!)</p>
<p>Or, <a id="downloadLink" download="cat.png">Click Here to Download!</a>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.desc {
text-align: center;
}
.outer, .wrap, .html2canvas, .image_text {
display: inline-block;
vertical-align: top;
}
.wrap {
text-align: center;
}
#imagewrap {
background-color: white;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript:
window.onload = function() {
html2canvas(document.getElementById("imagewrap"), {
onrendered: function(canvas) {
canvas.className = "html2canvas"; …Run Code Online (Sandbox Code Playgroud) 我按照本教程在我的网站上创建了“绘制显示”效果:http://thenewcode.com/1120/Scratch-Off-Reveal-with-HTML5-Canvas。我希望“正面”图像成为此视频资源,并且我还希望“显示”路径(或绘制的每个点)在绘制后经过设定时间后淡出(就像后面的淡出轨迹一样)鼠标),但不知道该怎么做。我尝试在每次调用后重新绘制 img drawDot(),但这似乎只是绘制整个“显示”图像。谢谢!
编辑:添加了将视频置于“前面”的请求
我正在尝试创建一个函数,该函数在保留值递归调用列表的同时查找函数的定点f(在其中的情况x = f x)。我在将递归调用追加到上一个列表的过程中遇到了麻烦。到目前为止,这是我的代码-谢谢!
fixpointL :: (Int -> Int) -> Int -> [Int]
fixpointL f x | x == (f x) = [x]
| otherwise = [x ++ fixpointL f (f x)]
Run Code Online (Sandbox Code Playgroud)