Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made it possible to change colour.

  • Loading branch information...
commit 1696486fda647ddb3bb582475fb3df4e0ebf793b 1 parent 77aa3c3
@ljos ljos authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/jquery.qrcode.js
View
10 src/jquery.qrcode.js
@@ -12,7 +12,9 @@
width : 256,
height : 256,
typeNumber : -1,
- correctLevel : QRErrorCorrectLevel.H
+ correctLevel : QRErrorCorrectLevel.H,
+ background : "#ffffff",
+ foreground : "#000000"
}, options);
var createCanvas = function(){
@@ -34,7 +36,7 @@
// 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) ? "#000000" : "#ffffff";
+ ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background;
ctx.fillRect( col*tileW, row*tileH, tileW, tileH );
}
}
@@ -55,7 +57,7 @@
.css("height", options.height+"px")
.css("border", "0px")
.css("border-collapse", "collapse")
- .css('background-color', "#ffffff");
+ .css('background-color', options.background);
// compute tileS percentage
var tileW = options.width / qrcode.getModuleCount();
@@ -68,7 +70,7 @@
for(var col = 0; col < qrcode.getModuleCount(); col++ ){
$('<td></td>')
.css('width', tileW+"px")
- .css('background-color', qrcode.isDark(row, col) ? "#000000" : "#ffffff")
+ .css('background-color', qrcode.isDark(row, col) ? options.foreground : options.background)
.appendTo($row);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.