public/plugins/jquery/jquery-qrcode/src/jquery.qrcode.js
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
(function ($) {
$.fn.qrcode = function (options) {
// if options is string,
if (typeof options === 'string') {
options = { text: options };
}
// set default values
// typeNumber < 1 for automatic calculation
options = $.extend({}, {
render: "canvas",
width: 256,
height: 256,
typeNumber: -1,
correctLevel: QRErrorCorrectLevel.H,
margin: 10,
strokeStyle: '#666', //边框线条颜色
fillStyle: '#fff', //圆角矩形填充颜色
background: "#ffffff",
foreground: "#000000"
}, options);
var createCanvas = function () {
// create the qrcode itself
var qrcode = new QRCode(options.typeNumber, options.correctLevel);
qrcode.addData(options.text);
qrcode.make();
// create canvas element
var canvas = document.createElement('canvas');
canvas.width = options.width;
canvas.height = options.height;
var ctx = canvas.getContext('2d');
// compute tileW/tileH based on options.width/options.height
var tileW = (options.width - (options.margin * 2)) / qrcode.getModuleCount();
var tileH = (options.height - (options.margin * 2)) / qrcode.getModuleCount();
ctx.fillStyle = options.background || '#fff';
ctx.fillRect(0, 0, options.width, options.height); //先刷上背景
// draw in the canvas
for (var row = 0; row < qrcode.getModuleCount(); row++) {
for (var col = 0; col < qrcode.getModuleCount(); col++) {
ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background;
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));
ctx.fillRect(Math.round(col * tileW + options.margin), Math.round(row * tileH + options.margin), w, h);
}
}
//增加以下代码,把图片画出来
if (options.imgsrc) {//传进来的图片地址
var maxImgW = (options.width - (options.margin * 2)) * 0.45,
maxImgH = (options.height - (options.margin * 2)) * 0.33;
//图片大小
options.imgWidth = options.imgWidth || options.width / 4.7;
options.imgHeight = options.imgHeight || options.height / 4.7;
后面还有 105 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。