Codice PHP:
function addCorners() {
var theimages = getImages('corner');
var image; var object; var canvas; var context; var i;
var iradius = null; var ishade = null; var ishadow = null;
var inverse = null; var classes = ''; var newClasses = '';
var maxdim = null; var style = null; var offset = null;
for (i=0;i<theimages.length;i++) {
image = theimages[i];
object = image.parentNode;
canvas = document.createElement('canvas');
if (canvas.getContext) {
classes = image.className.split(' ');
iradius = getClassValue(classes,"iradius");
ishadow = getClassValue(classes,"ishadow");
ishade = getClassValue(classes,"ishade");
inverse = getClassAttribute(classes,"inverse");
newClasses = getClasses(classes,"corner");
canvas.className = newClasses;
canvas.style.cssText = image.style.cssText;
canvas.style.height = image.height+'px';
canvas.style.width = image.width+'px';
canvas.height = image.height;
canvas.width = image.width;
canvas.src = image.src; canvas.alt = image.alt;
if(image.id!='') canvas.id = image.id;
if(image.title!='') canvas.title = image.title;
if(image.getAttribute('onclick')!='') canvas.setAttribute('onclick',image.getAttribute('onclick'));
maxdim = Math.min(canvas.width,canvas.height)/2;
iradius = Math.min(maxdim,iradius); offset = 4;
offset = (ishadow>0?(inverse>0?0:Math.min(Math.max(offset,iradius/2),16)):0);
context = canvas.getContext("2d");
if(image.getAttribute("usemap")) {
object.style.position = 'relative';
object.style.height = image.height+'px';
object.style.width = image.width+'px';
canvas.left = 0; canvas.top = 0;
canvas.style.position = 'absolute';
canvas.style.left = 0 + 'px';
canvas.style.top = 0 + 'px';
image.left = 0; image.top = 0;
image.style.position = 'absolute';
image.style.height = image.height+'px';
image.style.width = image.width+'px';
image.style.left = 0 + 'px';
image.style.top = 0 + 'px';
image.style.opacity = 0;
object.insertBefore(canvas,image);
}else {
object.replaceChild(canvas,image);
}
context.clearRect(0,0,canvas.width,canvas.height);
context.save();
if (ishadow>0 && inverse<=0) {
ishadow = ishadow/100;
if (iradius>0) {
roundedShadow(context,offset,offset,canvas.width-offset,canvas.height-offset,iradius,ishadow);
}else {
offset = 8;
roundedShadow(context,offset,offset,canvas.width-offset,canvas.height-offset,offset,ishadow);
}
}
globalCompositeOperation = "source-in";
if (iradius<=0) {
context.beginPath();
context.rect(0,0,canvas.width-offset,canvas.height-offset);
context.closePath();
}else {
roundedRect(context,0,0,canvas.width-offset,canvas.height-offset,iradius);
}
context.clip();
context.fillStyle = 'rgba(0,0,0,0)';
context.fillRect(0,0,canvas.width,canvas.height);
context.drawImage(image,0,0,canvas.width-offset,canvas.height-offset);
if (ishadow>0 && inverse>0) {
ishadow = ishadow/100;
if (iradius>0) {
addShine(context,canvas.width,canvas.height,iradius,ishadow,1);
roundedRect(context,0,0,canvas.width,canvas.height,iradius);
}else {
iradius = 16;
addShine(context,canvas.width,canvas.height,iradius,ishadow,1);
context.beginPath();
context.rect(0,0,canvas.width,canvas.height);
context.closePath();
}
context.strokeStyle = 'rgba(0,0,0,'+ishadow+')';
context.lineWidth = 2;
context.stroke();
}
if (ishade>0) {
ishade = ishade/100;
if (iradius<=0) iradius = 16;
addShade(context,canvas.width-offset,canvas.height-offset,iradius,ishade);
addShine(context,canvas.width-offset,canvas.height-offset,iradius,ishade);
}
canvas.style.visibility = 'visible';
}
}
}
var cornerOnload = window.onload;
window.onload = function () { if(cornerOnload) cornerOnload(); if(isIE){addIECorners(); }else {addCorners();}}
lo script è un pacchetto di html.it