zoukankan      html  css  js  c++  java
  • J2ME 游戏开发之线的绘制

    1. 方法

          drawLine(int x1, int y1, int x2, int y2)

          通过Graphics可以设置线是实线还是虚线

          Graphics.SOLID :虚线

          Graphics.DOTTED:实线

    2. 问题:

          1. 可否设置先的宽度

    3. 实例

    public class LineCanvas extends Canvas{
    
        protected void paint(Graphics g) {
            // TODO Auto-generated method stub
            
            clear(g);
            
            g.setColor(255,0,0);  //设置画笔的颜色
        
            g.drawLine(1, 30, 100, 10);  //绘制线: 开始点的坐标和结束点的坐标g
            
            g.setStrokeStyle(Graphics.DOTTED); //设置画笔的类型为实心的
            
            
            
            g.setColor(125,125,125);
            
            g.drawLine(1, 50, 100, 50);  
            
            g.setStrokeStyle(Graphics.SOLID);
            
        }
    
        
        private void clear(Graphics g){
            g.setColor(255,255,255);
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    }
    
  • 相关阅读:
    Linux脚本中使用特定JDK
    redis 模糊匹配批量清理 keys
    git push 本地项目推送到远程分支
    extentreports报告插件之extentX之服务搭建(三)
    extentreports报告插件与testng集成(二)
    extentreports报告插件与testng集成(一)
    初识ios自动化(一)
    css 选择器
    appium移动端测试之滑动(二)
    使用appium进行ios测试,启动inspector时遇到的问题(一)
  • 原文地址:https://www.cnblogs.com/zhangweia/p/2143487.html
Copyright © 2011-2022 走看看