
JSRadial 矩阵渐变是通过以下方式创建的。您可以尝试运行以下方法来使用矩阵创建 JS Radial 渐变 –
var canvas1 = document.getElementById("canvas"); //canvas1 variable to identify given canvasvar ctx1 = canvas.getContext("2d"); //This is used to tell context is 2D var gradient1 = ctx1.createRadialGradient(100/horizontalScale, 100/verticalScale, 100,100/horizontalScale,100/verticalScale,0); //This will create gradient with given canvas context gradient1.addColorStop(1,"green"); //New color green is added to gradientgradient1.addColorStop(0,"red"); //New color red is added to gradientctx1.scale(horizontalScale, verticalScale); //Context matrix ctx1 is shrinked according to horizaontaland vertical scalectx1.fillStyle = gradient; //Given gradient is drawnctx1.fillRect(0,0, 100/horizontalScale, 100/verticalScale); //Rectangle is stretched according to scalectx1.setTransform(0,1,1,0,1,1); //Context matrix is resetcanvas { background-color: purple;}//Canvas is drawn with background color purple
以上就是在HTML中使用矩阵创建JS径向渐变的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1552151.html
微信扫一扫
支付宝扫一扫