J2ME游戏开发之几何图形的绘制
2011-08-17 19:33
369 查看
1. 方法
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
a. 绘制空心矩形:
drawRect(int x, int y , int width, int height);
b. 绘制实心矩形:
fillRect(int x, int y , int width, int height);
c. 绘制椭圆
2. codedrawRect(int x, int y , int width, int height);
b. 绘制实心矩形:
fillRect(int x, int y , int width, int height);
c. 绘制椭圆
package com.sliw.graphics; import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; public class GeometryCanvas extends Canvas{ int startY = 10; int height = 20; int tip = 10; protected void paint(Graphics g) { // TODO Auto-generated method stub clear(g); /** 绘制空心的矩形 */ drawBlankRect(g); startY = startY + height + tip; /** 绘制实心的矩形**/ drawFillRect(g); startY = startY + height + tip; /** 绘制空心椭圆 **/ drawBlankOval(g); startY = startY + height + tip; /** 绘制实心椭圆 **/ drawFillOval(g); startY = startY + height + tip; /** 绘制类似进度条 **/ drawBlankAndFillOval(g); startY = startY + height + tip; /** 绘制圆**/ drawCycle(g); } private void clear(Graphics g){ g.setColor(255,255,255); g.fillRect(0, 0, getWidth(), getHeight()); } /** * drawRect(int x, int y , int width, int height); * @param g */ private void drawBlankRect(Graphics g){ g.setColor(255,0,0); g.drawRect(10, startY, 100, height); } private void drawFillRect(Graphics g){ g.setColor(0,255,0); g.fillRect(10, startY, 100, height); } /** * drawRoundRect(int x , int y , int width, int height, int arcWidth , int arcHeight); * arcWidth 是左右弧衔接起来凑成的弧的宽度 * arcHeight 则是上下弧衔接起来凑成的弧的高度 * @param g */ private void drawBlankOval(Graphics g){ g.setColor(0,0,255); g.drawRoundRect(10, startY, 100, height, 20, 20); } private void drawFillOval(Graphics g){ g.setColor(0,0,255); g.fillRoundRect(10, startY, 100, height, 20, 20); } /** * 通过叠加的方式 * @param g */ private void drawBlankAndFillOval(Graphics g){ g.setColor(0,0,255); g.drawRoundRect(10, startY, 100, height, 20, 20); g.fillRoundRect(10, startY, 20, 20, 20, 20); g.fillRect(20, startY, 60, 20); } /** * */ private void drawCycle(Graphics g){ g.setColor(150,150,150); g.drawRoundRect(10, startY, 60, 60, 60, 60); } }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
相关文章推荐
- 【Cocos2d-X开发学习笔记】第10期:渲染框架之几何图形的绘制DrawPrimitives
- 小例子学J2ME手机游戏开发――(二)图形和图像处理
- J2ME 游戏开发之--线的绘制
- Android简明开发教程十四:Context Menu 绘制几何图形
- Visual C++游戏开发笔记之四——游戏画面绘图(一)基本图形绘制
- 利用J2ME开发移动3D游戏之3D图形API
- 【Iphone 游戏开发之一】创建视图并绘制简单图形
- J2ME手机游戏开发--背景绘制
- 【Cocos2d-x游戏引擎开发笔记(18)】图形绘制
- 【图形学与游戏编程】开发笔记-入门篇3:图形绘制
- 【Visual C++】游戏开发笔记之四——游戏画面绘图(一)基本图形绘制
- SDL游戏开发系列第二话:基本图形的绘制
- 【Iphone 游戏开发之一】创建视图并绘制简单图形
- android游戏开发中图形绘制:Canvas和Paint的使用
- android游戏开发框架libgdx的使用(二)--图形绘制
- 【Visual C++】游戏开发笔记之四——游戏画面绘图(一)基本图形绘制
- J2ME游戏开发之--字符串的绘制
- 利用J2ME开发移动3D游戏之3D图形API
- 游戏开发之从零开始了解渲染管线【下】- 图形绘制管线及简易实现
- 【Cocos2d-X开发学习笔记】第10期:渲染框架之几何图形的绘制