raphael js rounded rectangle

Solutions on MaxInterview for raphael js rounded rectangle by the best coders in the world

showing results for - "raphael js rounded rectangle"
Alan
29 Mar 2018
1Raphael.fn.roundedRectangle = function (x, y, w, h, r1, r2, r3, r4){
2  var array = [];
3  array = array.concat(["M",x,r1+y, "Q",x,y, x+r1,y]); //A
4  array = array.concat(["L",x+w-r2,y, "Q",x+w,y, x+w,y+r2]); //B
5  array = array.concat(["L",x+w,y+h-r3, "Q",x+w,y+h, x+w-r3,y+h]); //C
6  array = array.concat(["L",x+r4,y+h, "Q",x,y+h, x,y+h-r4, "Z"]); //D
7
8  return this.path(array);
9};
10
11// Test
12var paper = Raphael("canvas", 840, 480);
13paper.roundedRectangle(10, 10, 80, 80, 0, 20, 0, 0);
14
Martín
25 Jun 2020
1Raphael.fn.roundedRectangle = function (x, y, w, h, r1, r2, r3, r4){
2  var array = [];
3  array = array.concat(["M",x+r1,y]);
4  array = array.concat(['l',w-r1-r2,0]);//T
5  array = array.concat(["q",r2,0, r2,r2]); //TR
6  array = array.concat(['l',0,h-r3-r2]);//R
7  array = array.concat(["q",0,r3, -r3,r3]); //BR
8  array = array.concat(['l',-w+r4+r3,0]);//B
9  array = array.concat(["q",-r4,0, -r4,-r4]); //BL
10  array = array.concat(['l',0,-h+r4+r1]);//L
11  array = array.concat(["q",0,-r1, r1,-r1]); //TL
12  array = array.concat(["z"]); //end
13
14  return this.path(array);
15};
16