登录
首页 » 其他 » Java中的Canvas绘图源码实例

Java中的Canvas绘图源码实例

于 2023-04-11 发布 文件大小:45.60 kB
0 175
下载积分: 2 下载次数: 1

代码说明:

Java中的Canvas绘图源码实例,主要是画线条、弧线、圆角矩形、三角形、文字、圆形等简单的几何图形,主要是通过创建DrawingCanvas对象canvas,为canvas设置命令监听者,实现接口CommandListener的方法,把缓冲区图像的内容绘制到画布上,画图部分代码:   int w = getWidth(); // 画布的宽度   int h = getHeight(); // 画布的高度   Image buffer = Image.createImage(w, h); // 用于绘图的缓冲图像   Graphics gc = buffer.getGraphics(); // 获取缓冲图像的图形环境   // 清除画布   public void clearScreen() {    gc.setColor(255,255,255); // 设置绘图颜色为白色    gc.fillRect(0,0,w,h); // 把缓冲图像填充为白色    gc.setColor(255,0,0); // 设置绘图颜色为红色   }   // 绘制直线   public void drawLine() {    setTitle("直线"); // 设置画布的标题    clearScreen(); // 清除画布    gc.drawLine(10,10,w-20,h-20); // 绘制黑色直线    gc.setColor(0,0,255); // 设置绘图颜色为蓝色    gc.drawLine(10,h/2,w-10,h/2); // 绘制蓝色直线   }   // 绘制弧   public void drawArc() {    setTitle("弧线和填充弧");    clearScreen();    gc.drawArc(5,5,w/2-20,h/2-20,60,216); // 绘制弧线    gc.drawArc(5,h/2-10,w/2-20,h/2-20,0,360); // 绘制圆    gc.setColor(0,0,255);    gc.fillArc(w/2,5,w/2-20,h/2-20,60,216); // 绘制填充弧线    gc

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 运动会分数统计
    运动会分数统计- The games score counts
    2022-08-19 08:50:12下载
    积分:1
  • 自适应信号处理,西蒙。海利经典教材,很全面详细,通俗易懂,我觉得是最好的自适应书籍!...
    自适应信号处理,西蒙。海利经典教材,很全面详细,通俗易懂,我觉得是最好的自适应书籍!-Adaptive signal processing, Simon. Haley classic textbook, it is fully detailed, easy to understand, I think is the best adaptive books!
    2023-02-10 14:50:05下载
    积分:1
  • 本例的源描述超过了演示版限制的300行, 如果您需要对进行编译与模拟,请与北京理工大学 ASIC研究所联系,获取Talent系统的完全...
    本例的源描述超过了演示版限制的300行, 如果您需要对其进行编译与模拟,请与北京理工大学 ASIC研究所联系,获取Talent系统的完全版本. 联系方法: 电话:010-68912434 信函:北京理工大学ASIC研究所 刘明业 教授收 邮编:100081-The source described in this case than the demo version of the 300 line limit, if you need to be compiled with the simulation, please contact ASIC Institute of Beijing Institute of Technology to obtain the complete version of Talent system. Contact: Tel :010-68912434 letter : Research Institute of Beijing Institute of Technology Professor Liu Mingye ASIC received Postcode: 100081
    2023-08-04 16:40:02下载
    积分:1
  • is a complete and detailed TCP/IP protocol guidelines. Description belongs to ev...
    是一本完整而详细的TCP/IP协议指南。描述了属于每一层的各个协议以及它们如何在不同操作系统中运行。作者用Lawrence Berkeley实验室的tcpdump程序来捕获不同操作系统和TCP/IP实现之间传输的不同分组。对tcpdump输出的研究可以帮助理解不同协议如何工作。 本书适合作为计算机专业学生学习网络的教材和教师参考书。也适用于研究网络的技术人员。 -is a complete and detailed TCP/IP protocol guidelines. Description belongs to every one of the various agreements and how they run different operating systems. Author Lawrence Berkeley Laboratory using the tcpdump procedures to catch different operating system Marketing and TCP/IP transmission between realize the different groups. Tcpdump output of the research can help understand how the different agreements work. The book suitable for students studying computer network of reference materials and teachers. Also applies to the study of the network technical staff.
    2022-02-01 21:12:03下载
    积分:1
  • DSP LF2407A 板上拨码开关例程 已跑通了
    DSP LF2407A 板上拨码开关例程 已跑通了-On-board DSP LF2407A DIP switch routine has been run over the
    2023-05-01 20:00:03下载
    积分:1
  • 普通通信信号bpsk,qpsk,qam调制解调
    普通通信信号bpsk,qpsk,qam调制解调-bpsk qpsk qam fsk gmsk modulation and demodulation
    2022-03-24 10:11:39下载
    积分:1
  • 我用VC6给别人编写的倒计时,可以用在PPT做的现场答题计时用...
    我用VC6给别人编写的倒计时,可以用在PPT做的现场答题计时用-I used VC6 prepared countdown to others, can be used in PPT answer time to do the scene with
    2022-04-13 06:11:10下载
    积分:1
  • 实现数据结构中的二叉树的创建及先序、中序、后序遍历
    实现数据结构中的二叉树的创建及先序、中序、后序遍历-data structure to create the binary tree and first sequence, sequence, after the preorder
    2022-11-19 09:10:04下载
    积分:1
  • java写的一个可收发EMAIL的类.可用中的方法直接收发EMAIL.
    java写的一个可收发EMAIL的类.可用其中的方法直接收发EMAIL.-wrote a java can send and receive e-mail and the like. The method can be used directly TX EMAIL.
    2022-02-01 20:13:47下载
    积分:1
  • VC++ 游戏编程-拼图游戏
    VC++ 游戏编程-拼图游戏,可选择游戏难度等级,分为初、中、高三级,另外还可自定义拼图图片,游戏中预设了三张拼图图片,不过经测试在Windows7下,好像不能加载这些外部的图片,程序还需要修正一下。源码 在VC6.0下完美编译成功。
    2022-07-08 09:07:39下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载