J2ME 游戏开发之颜色设置

1. J2ME开发的限制

    image

    2. 不支持线程组和守护线程

2. 颜色设置

public class ColorCanvas extends Canvas{



    protected void paint(Graphics g) {

        // TODO Auto-generated method stub

        //g.setColor(250,250,0);

        //设置颜色  0xARGB

        g.setColor(0x10ffff00);

        

        //绘制一个矩形

        g.fillRect(0, 0, getWidth(), getHeight());

        

        //获得颜色值

        int c = g.getColor();

        

        int dc = g.getDisplayColor(c);

        

        System.out.println("当前画面的颜色为:" + Integer.toHexString(c));

        

        System.out.println("当前画面的R值:" + g.getRedComponent());

        

        System.out.println("当前画面显示的颜色为:" + Integer.toHexString(dc));

        

        System.out.println("当前画面显示的灰度为:" + g.getGrayScale());

    }



}

你可能感兴趣的:(j2me)