This commit is contained in:
Leo_com
2018-04-27 12:01:06 +08:00
parent 4301d79b27
commit cd5d75f9cf
28 changed files with 22969 additions and 12 deletions

View File

@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "4865e11a-13e3-4831-b0d5-a17970fcc41a",
"isGroup": false,
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "53447054-ffc4-49ea-a72e-0d0659865944",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,44 @@
cc.Class({
extends: cc.Component,
properties: {
},
// use this for initialization
onLoad() {
this.init('http://forum.cocos.com/t/topic/44304/9');
},
init(url){
var ctx = this.node.addComponent(cc.Graphics);
if (typeof (url) !== 'string') {
console.log('url is not string',url);
return;
}
this.QRCreate(ctx, url);
},
QRCreate(ctx, url) {
var qrcode = new QRCode(-1, QRErrorCorrectLevel.H);
qrcode.addData(url);
qrcode.make();
ctx.fillColor = cc.Color.BLACK;
//块宽高
var tileW = this.node.width / qrcode.getModuleCount();
var tileH = this.node.height / qrcode.getModuleCount();
// draw in the Graphics
for (var row = 0; row < qrcode.getModuleCount(); row++) {
for (var col = 0; col < qrcode.getModuleCount(); col++) {
if (qrcode.isDark(row, col)) {
// ctx.fillColor = cc.Color.BLACK;
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW));
ctx.rect(Math.round(col * tileW), Math.round(row * tileH), w, h);
ctx.fill();
}
}
}
},
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "1f7a3ac7-08ff-44aa-b73d-012b68e649a4",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}