Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 133
Registered: ‎07-20-2009
My Device: Not Specified
Accepted Solution

Draw circle with gradient color

Dear all,

 Anyone know how to use Graphics to draw a circle with gradient color?

Thanks for help

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Draw circle with gradient color

Use the Graphics.drawShadedPath() method.

Developer
Posts: 133
Registered: ‎07-20-2009
My Device: Not Specified

Re: Draw circle with gradient color

thanks for your suggestion

 

Would you tell me how to use drawShadedPath() to draw a circle?

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Draw circle with gradient color

Here is some very simple code that should work.

 

 

//xc = x center
//yc = y center
//
//  Circle diagram
//           (xc-r),(yc-r){col2}  xc,(yc-r){col3) (xc+r),(yc-r){col4}
//           (xc-r), yc   {col1}  [xc, yc]        (xc+r),yc    {col5}
//           (xc-r),(yc+r){col8}  xc,(yc+r){col7} (xc+r),(yc+r){col6} 

int [] xpts = { (xc-r), (xc-r), xc, (xc+r), (xc+r), (xc+r), xc, (xc-r) };
int [] ypts = { yc, (yc-r), (yc-r), (yc-r), yc, (yc+r), (yc+r), (yc+r) };
byte [] types = { Graphics.CURVEDPATH_END_POINT, 
                  Graphics.CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
                  Graphics.CURVEDPATH_END_POINT, 
                  Graphics.CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
                  Graphics.CURVEDPATH_END_POINT, 
                  Graphics.CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT,
                  Graphics.CURVEDPATH_END_POINT, 
                  Graphics.CURVEDPATH_QUADRATIC_BEZIER_CONTROL_POINT };
int [] colors = { col1, col2, col3, col4, col5, col6, col7, col8 };

graphics.drawShadedPath(xpts,ypts,types,colors,null);

 

 

Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Draw circle with gradient color

Hi CMY,

 

am working with 4.7 version. i tried to execute ur code, but it showed me an error at

graphics.drawShadedPath(xpts,ypts,types,colors,null);

and my eclipse ide  allowed me to change to

g.drawShadedFilledPath(xpts,ypts,types,colors,null);

 

is there any version differences??

 

 

Thanks and Regards,
PraveenGoparaju.
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Draw circle with gradient color

Graphics.shadedFilledPath() is the correct function. I was writing it from memory and just had the function name wrong.