课外天地 李树青学习天地JavaME移动开发课件 → 程序代码——绘制太极图


  共有13888人关注过本帖树形打印复制链接

主题:程序代码——绘制太极图

帅哥哟,离线,有人找我吗?
admin
  1楼 博客 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 管理员
等级:管理员 帖子:1940 积分:26616 威望:0 精华:34 注册:2003/12/30 16:34:32
程序代码——绘制太极图  发帖心情 Post By:2008/10/8 22:48:34 [只看该作者]

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;

public class Exec extends MIDlet {
        private Display display;

        public Exec() {
                display = Display.getDisplay(this);
        }

        public void startApp() {

                display.setCurrent(new DrawPanel());
        }

        public void pauseApp() {
        }

        public void destroyApp(boolean unconditional) {
        }
}

class DrawPanel extends Canvas {
        public void paint(Graphics g) {
                int width = getWidth() * 2 / 3;
                int left = getWidth() * 1 / 6;
                int height = getHeight() * 2 / 3;
                int top = getHeight() * 1 / 6;

                g.setColor(0, 0, 0);
                g.fillArc(left, top, width, height, 90, 180);

                g.setColor(255, 255, 0);
                g.fillArc(left, top, width, height, 270, 180);

                g.setColor(0, 0, 0);
                g.fillArc(left * 2, top * 3, width / 2, height / 2, 270, 180);

                g.setColor(255, 255, 0);
                g.fillArc(left * 2, top, width / 2, height / 2, 0, 360);

                g.setColor(255, 255, 0);
                g.fillArc(left * 2 + left * 3 / 4, top * 3 + top * 3 / 4, width / 8,
                                height / 8, 0, 360);

                g.setColor(255, 0, 0);
                g.fillArc(left * 2 + left * 3 / 4, top + top * 3 / 4, width / 8,
                                height / 8, 0, 360);
        }
}

[此贴子已经被作者于2010-12-12 18:33:50编辑过]

 回到顶部