Adding round corner in "div" rendering mode

pull/3/head
olivier 12 years ago
parent 0f136f75cd
commit 357c5ecbc1

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jQuery.qrcode</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

@ -339,6 +339,7 @@
row, col, row, col,
containerCSS = { containerCSS = {
position: 'relative', position: 'relative',
left: 0, left: 0,
@ -365,14 +366,78 @@
for (row = 0; row < moduleCount; row += 1) { for (row = 0; row < moduleCount; row += 1) {
for (col = 0; col < moduleCount; col += 1) { for (col = 0; col < moduleCount; col += 1) {
if (qr.isDark(row, col)) {
$('<div/>') var rowT = row - 1,
.css(darkCSS) rowB = row + 1,
.css({ colL = col - 1,
colR = col + 1,
center = qr.isDark(row, col),
northwest = qr.isDark(rowT, colL),
north = qr.isDark(rowT, col),
northeast = qr.isDark(rowT, colR),
east = qr.isDark(row, colR),
southeast = qr.isDark(rowB, colR),
south = qr.isDark(rowB, col),
southwest = qr.isDark(rowB, colL),
west = qr.isDark(row, colL);
if (center) { //it's dark cell
var thenewdiv=$('<div/>')
.css(darkCSS)
.css({
left: offset + col * moduleSize, left: offset + col * moduleSize,
top: offset + row * moduleSize top: offset + row * moduleSize
}) });
.appendTo($div); if(!north && !west && !northwest){
thenewdiv.css('border-top-left-radius',settings.radius*moduleSize+'px');
}
if(!north && !east && !northeast) {
thenewdiv.css('border-top-right-radius',settings.radius*moduleSize+'px');
}
if(!south && !east && !southeast) {
thenewdiv.css('border-bottom-right-radius',settings.radius*moduleSize+'px');
}
if(!south && !west && !southwest) {
thenewdiv.css('border-bottom-left-radius',settings.radius*moduleSize+'px');
}
thenewdiv.appendTo($div);
}
else { // it's a ligth cell
console.log('*light('+col+','+row+')');
var thenewdiv=$('<div/>')
.css({
backgroundColor:settings.background,
padding:0,
margin:0,
height:moduleSize,
width:moduleSize,
});
if(north && west){
thenewdiv.css('border-top-left-radius',settings.radius*moduleSize+'px');
}
if(north && east) {
thenewdiv.css('border-top-right-radius',settings.radius*moduleSize+'px');
}
if(south && east) {
thenewdiv.css('border-bottom-right-radius',settings.radius*moduleSize+'px');
}
if(south && west) {
thenewdiv.css('border-bottom-left-radius',settings.radius*moduleSize+'px');
}
var theBgNewDiv=$('<div/>')
.css(darkCSS)
.css({
left: offset + col * moduleSize,
top: offset + row * moduleSize
});
thenewdiv.appendTo(theBgNewDiv);
theBgNewDiv.appendTo($div);
} }
} }
} }

Loading…
Cancel
Save