lib/tagcanvas.js
function RoundImage(i, r, iw, ih, s) {
  var cv, c, r1 = parseFloat(r), l = max(iw, ih);
  cv = NewCanvas(iw, ih);
  if(!cv)
    return null;
  if(r.indexOf('%') > 0)
    r1 = l * r1 / 100;
  else
    r1 = r1 * s;
  c = cv.getContext('2d');
  c.globalCompositeOperation = 'source-over';
  c.fillStyle = '#fff';
  if(r1 >= l/2) {
    r1 = min(iw,ih) / 2;
    c.beginPath();
    c.moveTo(iw/2,ih/2);
    c.arc(iw/2,ih/2,r1,0,2*Math.PI,false);
    c.fill();
    c.closePath();
  } else {
    r1 = min(iw/2,ih/2,r1);
    RRect(c, 0, 0, iw, ih, r1, true);
    c.fill();
  }
  c.globalCompositeOperation = 'source-in';
  c.drawImage(i, 0, 0, iw, ih);
  return cv;
}
function RoundImage(i, r, iw, ih, s) {
  var cv, c, r1 = parseFloat(r), l = max(iw, ih);
  cv = NewCanvas(iw, ih);
  if(!cv)
    return null;
  if(r.indexOf('%') > 0)
    r1 = l * r1 / 100;
  else
    r1 = r1 * s;
  c = cv.getContext('2d');
  c.globalCompositeOperation = 'source-over';
  c.fillStyle = '#fff';
  if(r1 >= l/2) {
    r1 = min(iw,ih) / 2;
    c.beginPath();
    c.moveTo(iw/2,ih/2);
    c.arc(iw/2,ih/2,r1,0,2*Math.PI,false);
    c.fill();
    c.closePath();
  } else {
    r1 = min(iw/2,ih/2,r1);
    RRect(c, 0, 0, iw, ih, r1, true);
    c.fill();
  }
  c.globalCompositeOperation = 'source-in';
  c.drawImage(i, 0, 0, iw, ih);
  return cv;
}
function RoundImage ( i , r , iw , ih , s ) { var cv , c , r1 = parseFloat ( r ) , l = max ( iw , ih ) ; cv = NewCanvas ( iw , ih ) ; if ( ! cv ) return null ; if ( r . indexOf ( '%' ) > 0 ) r1 = l * r1 / 100 ; else r1 = r1 * s ; c = cv . getContext ( '2d' ) ; c . globalCompositeOperation = 'source-over' ; c . fillStyle = '#fff' ; if ( r1 >= l / 2 ) { r1 = min ( iw , ih ) / 2 ; c . beginPath ( ) ; c . moveTo ( iw / 2 , ih / 2 ) ; c . arc ( iw / 2 , ih / 2 , r1 , 0 , 2 * Math . PI , false ) ; c . fill ( ) ; c . closePath ( ) ; } else { r1 = min ( iw / 2 , ih / 2 , r1 ) ; RRect ( c , 0 , 0 , iw , ih , r1 , true ) ; c . fill ( ) ; } c . globalCompositeOperation = 'source-in' ; c . drawImage ( i , 0 , 0 , iw , ih ) ; return cv ; }
Rounds off the corners of an image
Rounds off the corners of an image