小编Jak*_*nda的帖子

在bash脚本中乘以字符串

我知道如果我print ("f" + 2 * "o")在python中输出将是foo.

但是如何在bash脚本中执行相同的操作呢?

string bash concatenation

5
推荐指数
3
解决办法
5032
查看次数

如何在 HTML5 画布中显示更平滑的渐变?

我的网页中有一个 html5 画布。我只在其中放了一个图像和一个渐变。

Canvas 使用 thic JS 代码来绘制自己:

var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.clearRect ( 0 , 0 , canvas.width, canvas.height );
var img = document.getElementById("slika");
ctx.drawImage(img, 0, 0,canvas.width,canvas.height);
var grd = ctx.createLinearGradient(x-400, 0, x, 0)
grd.addColorStop(0.3,"hsla(360, 100%, 100%, 0)");
grd.addColorStop(1,"hsla(360, 100%, 100%, 0.8)");
ctx.fillStyle=grd;
ctx.fillRect(0,0,canvas.width,canvas.height);

ctx.font = "70px Arial";
ctx.fillStyle = "black"
ctx.textAlign = "right";
ctx.fillText(textInput,canvas.width-50,canvas.height-120);
Run Code Online (Sandbox Code Playgroud)

当它显示时,过渡不是很平滑,它只是从某处开始并在某处结束。

它看起来像这样:

http://kendaj.net46.net/canvas-StackOverflow.png

我希望过渡更平滑(我不是说更宽的梯度)。

有没有办法做到这一点?

谢谢回答。

html transition gradient canvas smooth

2
推荐指数
1
解决办法
1355
查看次数

标签 统计

bash ×1

canvas ×1

concatenation ×1

gradient ×1

html ×1

smooth ×1

string ×1

transition ×1