e586. Drawing Simple Shapes
There are two ways to draw basic shapes like circles, ovals, lines, arcs, squares, rectangles, rounded rectangles, and polygons. The first is to use specific drawing methods like Graphics.drawOval()
. This example uses these methods. The second is to construct a shape and then use Graphics2D.draw()
to draw the shape. See the java.awt.geom
package for examples that create shapes.
// See e575 The Quintessential Drawing Program
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g; g2d.drawLine(x1, y1, x2, y2);
g2d.drawOval(x, y, w, h);
g2d.drawRect(x, y, w, h); // A start angle of 0 represents a 3 o'clock position, 90 represents a 12 o'clock position,
// and -90 (or 270) represents a 6 o'clock position
int startAngle = 45;
int arcAngle = -60;
g2d.drawArc(x, y, w, h, startAngle, arcAngle); g2d.drawRoundRect(x, y, w, h, arcWidth, arcHeight); Polygon polygon = new Polygon();
polygon.addPoint(x, y);
// Add more points...
g2d.drawPolygon(polygon);
}
Related Examples |
e586. Drawing Simple Shapes的更多相关文章
- LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)
1285 - Drawing Simple Polygon PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- e591. Drawing Simple Text
See also e575 The Quintessential Drawing Program. public void paint(Graphics g) { // Set the desired ...
- Drawing Simple Polygon(Create Simple Polygon from unordered points by angle sorting)
Keywords: 极角排序, Simple Polygon Generation Given set of points in the plane, your task is to draw a p ...
- LightOj1285 - Drawing Simple Polygon(连接多边形各点)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1285 题意:给你一些点,然后把它们用一条线把它们连起来,构成一个多边形,不能有相交,必 ...
- e575. The Quintessential Drawing Program
To draw on the screen, it is first necessary to subclass a JComponent and override its paint() metho ...
- e577. Enabling Antialiasing
// See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graph ...
- python编程学习--Pygame - Python游戏编程入门(0)---转载
原文地址:https://www.cnblogs.com/wuzhanpeng/p/4261015.html 引言 博客刚开,想把最近学习的东西记录下来,算是一种笔记.最近打算开始学习Python,因 ...
- Pygame - Python游戏编程入门(0) 转
博客刚开,想把最近学习的东西记录下来,算是一种笔记.最近打算开始学习Python,因为我感觉Python是一门很有意思的语言,很早以前就想学了(碍于懒),它的功能很强大,你可以用它来做科学运算,或者数 ...
- Pygame - Python游戏编程入门
>>> import pygame>>> print(pygame.ver)1.9.2a0 如果没有报错,应该是安装好了~ 如果报错找不到模块,很可能是安装版本的问 ...
随机推荐
- (一)RocketMq入门之安装运行
一.几个重要的地址 Git地址:https://github.com/apache/incubator-rocketmq 编译好的文件:https://rocketmq.incubator.apach ...
- 计算机通信协议之OSI参考模型
OSI参考模型 在OSI参考模型之前人类对计算机结构的研究就已经进行了太多的讨论,最终通过了作为通信协议设计指标的OSI参考模型.这个协议将通信协议中必要的功能分成了七个部分.通过这些分层使得那些比较 ...
- 深入理解 Session 与 Cookie
Session 与 Cookie 的作用都是为了保持访问用户与后端服务器的交互状态.它们有各自的优点,也有各自的缺陷,然而具有讽刺意味的是它们的优点和它们的使用场景又是矛盾的.例如,使用 Cookie ...
- for循环中的break与continue
break: 跳出循环,执行for循环下面的语句.continue: 跳出本次循环,执行下次循环.
- activiti自己定义流程之Spring整合activiti-modeler实例(一):环境搭建
项目中须要整合activiti-modeler自己定义流程,找了非常多资料后,最终成功的跳转到activiti-modeler流程设计界面.下面是记录: 一.整合基础:eclipse4.4.1.tom ...
- Bash编程的test和条件语句
1.if语句一句条件判断结果选择执行路径.最简单的if-then句型: if command //如果command的退出状态为0,执行body then body fi 重点:if认为command ...
- 【Android】21.2 2D图形图像处理(Canvas和Paint)
分类:C#.Android.VS2015: 创建日期:2016-03-19 一.Canvas对象简介 画布(Canvas对象)是与System.Drawing或iOS核心图形等传统框架非常类似的另一种 ...
- 每日英语:Some Chinese Students Stay Home to Get Ahead
Li Shan's oldest son was the perfect candidate to join the throngs of Chinese students studying abro ...
- vim学习日志(5):vim下wimrc的配置,解决中文乱码问题
解决linux下vim乱码的情况:(修改vimrc的内容) 全局的情况下:即所有用户都能用这个配置 文件地址:/etc/vimrc 在文件中添加: ,ucs-bom,gb18030,gbk,gb231 ...
- Oracle PLSQL Demo - 17.游标查询个别字段(非整表)
declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; v_empno scott.emp.empno% ...