Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Talk:Draw Gradient in Java ME

From Wiki
Jump to: navigation, search
{{{width}}}
19 Sep
2009
Article Review by Larry101 (20090919)

This article provides a useful class for creating linear gradient paint effects in Java ME. The standard Graphics class used in Canvas and GameCanvas-based applications does not allow for the easy creation of gradients. The code example provided addresses this limitation by allowing programmers to create rectangles filled with either vertical and horizontal gradients. The programmer is simply required to provide the two-colours required for the gradient, the coordinates of the top-left corner and the width and height of the rectangle. The class then takes care of painting the gradient, interpolating between the two colours in order to smoothly transition from one to the other.

The code in this class provides for reasonably smooth gradients in Java ME and is very useful given the limitations of the standard Graphics class. This approach is better than using an image containing a gradient as a background, as it is difficult to scale an image correctly for all possible screen aspect ratios. Images also increase JAR file size.


{{{width}}}
22 Sep
2009
Article Review by vkmunjpara (20090922)

This article is good explicated with methods and with an example in an easy way. This article shows how to draw gradient on canvas. gradientBox() method addresses some calculation needed for setting gradient on to canvas.

And these functions are applied in paint method defined in GradientRectCanvas wrap.


 

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×