Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

raphael js rounded rectangle

Raphael.fn.roundedRectangle = function (x, y, w, h, r1, r2, r3, r4){
  var array = [];
  array = array.concat(["M",x,r1+y, "Q",x,y, x+r1,y]); //A
  array = array.concat(["L",x+w-r2,y, "Q",x+w,y, x+w,y+r2]); //B
  array = array.concat(["L",x+w,y+h-r3, "Q",x+w,y+h, x+w-r3,y+h]); //C
  array = array.concat(["L",x+r4,y+h, "Q",x,y+h, x,y+h-r4, "Z"]); //D

  return this.path(array);
};

// Test
var paper = Raphael("canvas", 840, 480);
paper.roundedRectangle(10, 10, 80, 80, 0, 20, 0, 0);
Comment

raphael js rounded rectangle (another solution)

Raphael.fn.roundedRectangle = function (x, y, w, h, r1, r2, r3, r4){
  var array = [];
  array = array.concat(["M",x+r1,y]);
  array = array.concat(['l',w-r1-r2,0]);//T
  array = array.concat(["q",r2,0, r2,r2]); //TR
  array = array.concat(['l',0,h-r3-r2]);//R
  array = array.concat(["q",0,r3, -r3,r3]); //BR
  array = array.concat(['l',-w+r4+r3,0]);//B
  array = array.concat(["q",-r4,0, -r4,-r4]); //BL
  array = array.concat(['l',0,-h+r4+r1]);//L
  array = array.concat(["q",0,-r1, r1,-r1]); //TL
  array = array.concat(["z"]); //end

  return this.path(array);
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to set up click event listeners javascript 
Javascript :: convert jquery hide function to pure javascript code 
Javascript :: const { message } 
Javascript :: Scratch Addon userscript 
Javascript :: knex update and list all record mysql 
Javascript :: sending string from jquery ajax to asp.net mvc controller. 
Javascript :: create-react-app height issues with flex 
Javascript :: how to use mixed quotes in a sentence in js 
Javascript :: react native parent opcaity not affecting text 
Javascript :: javascript reflections iterate all members 
Javascript :: npm ERR! peer react@"^15.x.x" from react-html-table-to-excel@2.0.0 
Javascript :: How do you remove property name from this code? const foo = { name; “albert” }; 
Javascript :: read url jsf 
Javascript :: rest client vs code 
Javascript :: babel 7 ReferenceError: regeneratorRuntime 
Javascript :: time zone npm in next js 
Javascript :: Masonry js css 
Javascript :: momentjs isomonth 
Javascript :: hover inline css 
Javascript :: KIVIN 
Javascript :: how to set a custom error message to a form in angular 
Javascript :: Could not parse as expression: "1, "desc" DataTable 
Javascript :: create random salt js 
Javascript :: how to express all characters in keyboard in js reg exp 
Javascript :: H.C.F Calculation Program 
Javascript :: blockchain.info/pushtx 
Javascript :: class function constructor 
Javascript :: Get JSON Key In Array Alternative Syntax 
Javascript :: react with two components render empty 
Javascript :: Class Has a Constructor Function 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =