@@ -548,6 +548,100 @@ var Graphics = new Class({
548548 return this ;
549549 } ,
550550
551+ /**
552+ * Fill a rounded rectangle with the given position, size and radius.
553+ *
554+ * @method Phaser.GameObjects.Graphics#fillRoundedRect
555+ * @since 3.11.0
556+ *
557+ * @param {number } x - The x coordinate of the top-left of the rectangle.
558+ * @param {number } y - The y coordinate of the top-left of the rectangle.
559+ * @param {number } width - The width of the rectangle.
560+ * @param {number } height - The height of the rectangle.
561+ * @param {number } [radius = 20] - The corner radius; It can also be an object to specify different radii for corners
562+ * @param {number } [radius.tl = 0] Top left
563+ * @param {number } [radius.tr = 0] Top right
564+ * @param {number } [radius.br = 0] Bottom right
565+ * @param {number } [radius.bl = 0] Bottom left
566+ *
567+ * @return {Phaser.GameObjects.Graphics } This Game Object.
568+ */
569+ fillRoundedRect : function ( x , y , width , height , radius )
570+ {
571+ if ( typeof radius === 'number' ) {
572+ radius = { tl : radius , tr : radius , br : radius , bl : radius } ;
573+ } else if ( typeof radius === 'object' ) {
574+ var defaultRadius = { tl : 0 , tr : 0 , br : 0 , bl : 0 } ;
575+ for ( var side in defaultRadius ) {
576+ radius [ side ] = radius [ side ] || defaultRadius [ side ] ;
577+ }
578+ }
579+ else {
580+ radius = { tl : 20 , tr : 20 , br : 20 , bl : 20 } ;
581+ }
582+
583+ this . beginPath ( ) ;
584+ this . moveTo ( x + radius . tl , y ) ;
585+ this . lineTo ( x + width - radius . tr , y ) ;
586+ this . arc ( x + width - radius . tr , y + radius . tr , radius . tr , - MATH_CONST . TAU , 0 ) ;
587+ this . lineTo ( x + width , y + height - radius . br ) ;
588+ this . arc ( x + width - radius . br , y + height - radius . br , radius . br , 0 , MATH_CONST . TAU ) ;
589+ this . lineTo ( x + radius . bl , y + height ) ;
590+ this . arc ( x + radius . bl , y + height - radius . bl , radius . bl , MATH_CONST . TAU , Math . PI ) ;
591+ this . lineTo ( x , y + radius . tl ) ;
592+ this . arc ( x + radius . tl , y + radius . tl , radius . tl , - Math . PI , - MATH_CONST . TAU ) ;
593+ this . fillPath ( ) ;
594+
595+ return this ;
596+ } ,
597+
598+ /**
599+ * Stroke a rounded rectangle with the given position, size and radius.
600+ *
601+ * @method Phaser.GameObjects.Graphics#strokeRoundedRect
602+ * @since 3.11.0
603+ *
604+ * @param {number } x - The x coordinate of the top-left of the rectangle.
605+ * @param {number } y - The y coordinate of the top-left of the rectangle.
606+ * @param {number } width - The width of the rectangle.
607+ * @param {number } height - The height of the rectangle.
608+ * @param {number } [radius = 20] - The corner radius; It can also be an object to specify different radii for corners
609+ * @param {number } [radius.tl = 0] Top left
610+ * @param {number } [radius.tr = 0] Top right
611+ * @param {number } [radius.br = 0] Bottom right
612+ * @param {number } [radius.bl = 0] Bottom left
613+ *
614+ * @return {Phaser.GameObjects.Graphics } This Game Object.
615+ */
616+ strokeRoundedRect : function ( x , y , width , height , radius )
617+ {
618+ if ( typeof radius === 'number' ) {
619+ radius = { tl : radius , tr : radius , br : radius , bl : radius } ;
620+ } else if ( typeof radius === 'object' ) {
621+ var defaultRadius = { tl : 0 , tr : 0 , br : 0 , bl : 0 } ;
622+ for ( var side in defaultRadius ) {
623+ radius [ side ] = radius [ side ] || defaultRadius [ side ] ;
624+ }
625+ }
626+ else {
627+ radius = { tl : 20 , tr : 20 , br : 20 , bl : 20 } ;
628+ }
629+
630+ this . beginPath ( ) ;
631+ this . moveTo ( x + radius . tl , y ) ;
632+ this . lineTo ( x + width - radius . tr , y ) ;
633+ this . arc ( x + width - radius . tr , y + radius . tr , radius . tr , - MATH_CONST . TAU , 0 ) ;
634+ this . lineTo ( x + width , y + height - radius . br ) ;
635+ this . arc ( x + width - radius . br , y + height - radius . br , radius . br , 0 , MATH_CONST . TAU ) ;
636+ this . lineTo ( x + radius . bl , y + height ) ;
637+ this . arc ( x + radius . bl , y + height - radius . bl , radius . bl , MATH_CONST . TAU , Math . PI ) ;
638+ this . lineTo ( x , y + radius . tl ) ;
639+ this . arc ( x + radius . tl , y + radius . tl , radius . tl , - Math . PI , - MATH_CONST . TAU ) ;
640+ this . strokePath ( ) ;
641+
642+ return this ;
643+ } ,
644+
551645 /**
552646 * Fill the given point.
553647 *
0 commit comments