zoukankan      html  css  js  c++  java
  • Graphics samples

    绘制二次曲线:

    public void paint(Graphics g) {
    // TODO 自动生成的方法存根
    super.paint(g);


    Graphics2D g2=(Graphics2D)g;
    QuadCurve2D.Double curle=new QuadCurve2D.Double(60,20,120,100,180,20);
    g2.draw(curle);
    }

    绘制三次曲线:

    public void paint(Graphics g) {
    // TODO 自动生成的方法存根
    super.paint(g);


    Graphics2D g2=(Graphics2D)g;
    QuadCurve2D.Double curle=new QuadCurve2D.Double(60,20,120,100,180,20);
    g2.draw(curle);
    }

    绘制文本:

    public void paint(Graphics g) {
    // TODO 自动生成的方法存根
    super.paint(g);
    String str=new String("静夜思");
    int x=50;
    int y=50;
    g.drawString(str, x, y);
    }

    设置文本字体:

    Font font=new Font(TOOL_TIP_TEXT_KEY, Font.BOLD, 26);
    g.setFont(font);

    设置文本颜色:

    Font font=new Font(TOOL_TIP_TEXT_KEY, Font.BOLD, 26);
    g.setFont(font);

    设置笔画的粗细:

    Graphics2D g2=(Graphics2D)g;


    Stroke st=new BasicStroke(20);
    g2.setStroke(st);

    g2.drawLine(0, 0, 200, 200);

    设置笔画样式及连接方式:

    Stroke st=new BasicStroke(20,BasicStroke.JOIN_ROUND,BasicStroke.JOIN_BEVEL);
    g2.setStroke(st);

    设置虚线模式:

    float[] arr={10.0f,10.0f};

    Stroke st=new BasicStroke(2,BasicStroke.JOIN_ROUND,BasicStroke.JOIN_BEVEL,1.0f, arr,0);
    g2.setStroke(st);

  • 相关阅读:
    缓存读写策略
    支撑京东小程序的开发框架 「Taro」
    Zookeeper vs Etcd
    前端开发利器 Web Replay
    kafka 中 zookeeper 具体是做什么的?
    newSQL 到底是什么?
    zookeeper配置集群
    zookeeper配置文件说明
    ssh远程访问-提示密钥不安全
    Nodejs-log4js使用配置
  • 原文地址:https://www.cnblogs.com/mafeng/p/4456747.html
Copyright © 2011-2022 走看看