Draw.rect = function(x, y, w, h) {
  Canvas.context.beginPath();
  switch(Draw.currentRectMode) {
    case CORNER: Canvas.context.fillRect(x, y, w, h);
                 Canvas.context.strokeRect(x, y, w, h); break;
    case CORNERS: Canvas.context.fillRect(x, y, w - x, h - y);
                 Canvas.context.strokeRect(x, y, w - x, h - y); break;
    case RADIUS: Canvas.context.fillRect(x + w/2, y + h/2, w * 2, h * 2);
                 Canvas.context.strokeRect(x + w/2, y + h/2, w * 2, h * 2); break;
    case CENTER: Canvas.context.fillRect(x + w/2, y + h/2, w, h);
                 Canvas.context.strokeRect(x + w/2, y + h/2, w, h); break;
  }
  Canvas.context.fill();
  Canvas.context.stroke();
};

@@ -28,41 +28,100 @@
 w, h
-) %7B%0A  Canvas.context.beginPath();
+, tl, tr, br, bl) %7B%0A  var realX = x, %0A      realY = y,%0A      realW = w, %0A      realH = h;%0A  
 %0A  s
@@ -169,587 +169,903 @@
 RNER
+S
 : 
-Canvas.context.fillRect(x, y, w, h);%0A                 Canvas.context.strokeRect(x, y, w, h); break;%0A    case CORNERS: Canvas.context.fillRect(x, y, w - x, h - y);%0A                 Canvas.context.strokeRect(x, y, w - x, h - y); break;%0A    case RADIUS: Canvas.context.fillRect(x +
+realW = w - x;%0A                  realH = h - y; break;%0A    case RADIUS: realX = x + w/2;%0A                 realY = y + h/2;%0A                 realW = w * 2;%0A                 realH = h * 2; break;%0A    case CENTER: realX = x -
  w/2
-, y +
+; %0A                 realY = y -
  h/2
-, w * 2, h * 2);%0A                 Canvas.context.strokeRect(x + w/2, y + h/2, w * 2, h * 2); break;%0A    case CENTER: Canvas.context.fillRect(x + w/2, y + h/2, w, h);%0A                 Canvas.context.strokeRect(x + w/2, y + h/2, w, h); break
+; break;%0A  %7D%0A  %0A  tl = tl %7C%7C 0;%0A  tr = tr %7C%7C tl;%0A  br = br %7C%7C tl;%0A  bl = bl %7C%7C tl;%0A  %0A  ctx.beginPath();%0A  ctx.moveTo(realX + tl, realY);%0A  ctx.lineTo(realX + realW - tr, realY);%0A  ctx.quadraticCurveTo(realX + realW, realY, realX + realW, realY + tr);%0A  ctx.lineTo(realX + realW, realY + realH - br);%0A  ctx.quadraticCurveTo(realX + realW, realY + realH, realX + realW - br, realY + realH);%0A  ctx.lineTo(realX + bl, realY + realH);%0A  ctx.quadraticCurveTo(x, realY + realH, realX, realY + realH - bl);%0A  ctx.lineTo(realX, realY + tl);%0A  ctx.quadraticCurveTo(realX, realY, realX + tl, realY);%0A  ctx.closePath()
 ;%0A  
-%7D
 %0A  
-Canvas.context.fill();%0A  Canvas.context
+ctx.fill();%0A  ctx
 .str

Update rect.js