Skip to main content

Color Gradient in an rectangle

2 replies [Last post]
mkant
Offline
Joined: 2010-02-03

Hello,

I would draw an rectangle with a color gradient (blue to red)

But the Graphics.setPaint method doesn´t work in phoneme personale profile.

I have tried it with following code, but it is very slow. The rectangle is often repaint, so I need
a fast workaround.

for(int i=1; i < this.width ; i++){
for(int y=1; y < this.height ; y++){
int rot = (int) Math.floor( 255*i/this.width );
int blau = (int) Math.floor( 255*y/this.height );
_g.setColor(new Color(rot,0,blau));
_g.fillRect(i,y,1,1);
}
}

Does anybody know a workoaround for a color gradeint?

Thank you.

Best tregards,

Mathias

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hello,
>
> I would draw an rectangle with a color gradient (blue to red)
>
>

Hi Mathias,

If you want to speed up drawing a color gradient on phoneME Advanced
Personal Profile, one way is to pre-render the color gradient rectangle
as an image off-device using a 3rd party tool, such as Gimp. Save the
image as a PNG or GIF file, then transfer the image file to your device
and use Personal Profile to load that image file and drawImage to your
screen.

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

mkant
Offline
Joined: 2010-02-03

Thank you. I will try this.

Best regards,

Mathias