[Function] tạo nền gradient cho canvas
15.07.2014/13:24
Ae muốn dùng lại nhiều lần thì cho cái trong paint vào hàm nha! Biến trong hàm làx,y,w,h,color1,color2import javax.microedition.lcdui.*;
import com.jappit.wiki.gradientrect.graphics.Gradient;
publicclassCanextendsCanvas {int orientation;
int prop;
int left=0;
int top=0;
int height=160;
int width=128;
int VERTICAL=0;
int color1=0xff0000;
int color2=0x0000ff;
int color;
public Can() {
setFullScreenMode(true);
}
publicvoid paint(Graphics g) {
setFullScreenMode(true);
int max = orientation == VERTICAL ? height : width;
for(int i = 0; i < max; i++){
prop=max * (max - 1 - i) / (max - 1);
color = ((((color1 >> 16) & 0xff) * prop +((color2 >> 16) & 0xff) * (max - prop)) / max)<< 16 | ((((color1 >> 8 ) & 0xff) * prop +((color2 >> 8 ) & 0xff) * (max - prop)) / max)<< 8 | ((((color1 >> 0) & 0xff) * prop +((color2 >> 0) & 0xff) * (max - prop)) / max);
g.setColor(color);
if(orientation == VERTICAL){
g.drawRect(left+i, top+i,width-i,height-i);
g.setColor(0,0,0);
g.drawString("hj"+max+prop+color,0,50,20);
}else{
g.drawLine(left + i, top, left + i, top + height - 1);
}
}
}
}
Tag:
Bạn đến từ:
Tool tiện ích admin,KhoGame360,Blog thủ thuật,kenh380
,truyen23h
,tai hinh nen naruto,kenhpro - wap hay,vmt - wap hay, Trần Phú Hiền Blog
,truyen23h
,tai hinh nen naruto,kenhpro - wap hay,vmt - wap hay, Trần Phú Hiền Blog