• 本站域名:OceanCoder.cn 若您喜欢本站,请添加至收藏夹!
  • 网站少部分资源来源自网络,如有侵犯您的权益,请联系站长删除!
  • 本站所有文章,除特殊标明外,皆为本人原创,转载请注明出处,谢谢合作!
  • 本站所下载的资源,若无特殊说明,使用统一解压密码:oceancoder.cn
  • 本站已实现布局自适应,支持手机端、pad端访问,欢迎体验
  • 本站部分资源可通过微信公众号留言获取,欢迎体验

js签名jSignature插件动态设置笔触颜色

HTML+CSS+JS OceanCoder 2020-05-09 4371 次浏览 0个评论

使用方法就不介绍了,去下面看吧

https://github.com/brinley/jSignature


一、问题描述

想通过颜色对话框动态设置签名的笔触颜色,但网上找了很久没找到方法,在发布页找到了下面这句话

updateSetting takes three arguments - setting name, new value, boolean value if the change should affect current signature or future strokes. This allows you to update certain settings like lineWidth or line color and with the third argument you can make the change apply to the existing strokes. At present, updating change to existing strokes only works with a few settings like color. Returns the updated value.


二、解决办法

1、添加颜色对话框

<input type="color" id="fcolor" onchange="changefcolor()">

2、js代码这样写

function changefcolor() {

    ////此方法表面有效,但实际颜色未成功设置,导出的图片也无颜色,放弃
    ////var context2D = $("#signature").find('canvas')[0].getContext('2d');
    ////context2D.strokeStyle = $("#fcolor").val();

        
    //使用前,清除现有笔迹,因为一次只允许使用一种颜色
    $('#signature').jSignature("updateSetting", "color", $("#fcolor").val(), true);
}


已有 4371 位网友参与,快来吐槽:

发表评论