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());
        }
    }
    
  • 相关阅读:
    【leetcode】三维形体投影面积
    【leetcode】区域和检索
    【leetcode】二叉搜索树的范围和
    【leetcode】数组序号转换
    【leetcode】赎金信
    【leetcode】矩形重叠
    【leetcode】转变日期格式
    053-158
    053-268
    053-160
  • 原文地址:https://www.cnblogs.com/zhangweia/p/2143487.html
Copyright © 2011-2022 走看看