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 如果没有报错,应该是安装好了~ 如果报错找不到模块,很可能是安装版本的问 ...
随机推荐
- tmux安装
安装tmux sudo yum -y install tmux 修改tmux配置 cat > /root/.tmux.conf <<EOF set-option -g default ...
- MIME类型释义--MIME类型大全--web.xml中有关<mime-mapping>配置说明
最早的HTTP协议中,并没有附加的数据类型信息,所有传送的数据都被客户程序解释为超文本标记语言HTML 文档,而为了支持多媒体数据类型,HTTP协议中就使用了附加在文档之前的MIME数据类型信息来标识 ...
- 微服务架构的进程间通信(IPC)
先抛出几个问题: 微服务架构的交互模式有哪些? 微服务常用的进程间通信技术有哪些? 如何处理部分请求失败? API的定义需要注意的事项有哪些 微服务的通信机制与SOA的通信机制之间的关系与区别 微服务 ...
- vim:过一个字符
vim由插入模式进入编辑模式,会向前移动一个字符. 利用这个特性,我们可以用他来过一个字符. 什么情况需要过字符?比如:右括号.右引号等等,在括号中间,直接跳出,而不用方向键移动. 向前过一个字符,应 ...
- PHP 对 memcache操作类
<span style="font-size:18px;">class myMemcache { private $memcache; /** * 一般建议这2个值做成 ...
- 【HBase】Rowkey设计【转】
本章将深入介绍由HBase的存储架构在设计上带来的影响.如何设计表.row key.column等等,尽可能地使用到HBase存储上的优势. Key设计 HBase有两个基础的主键结构:row key ...
- Zookeeper已经分布式环境中的假死脑裂
Zookeeper简介 在上班之前都不知道有这样一个东西,在开始说假死脑裂之前先说说Zookeeper吧. Zookeeper zookeeper是一个分布式应用程序的协调服务.它是一个为分布式应用提 ...
- LINQ架构简单描述
写在前面的话:课堂上老师只是简单提了一下LINQ,当时听着老师对它的描述,感觉非常神奇,不用去操作繁琐的SQL语句了,读取数据库的操作居然能向写C#代码一样方便,但是一直没有机会去学习使用它. LIN ...
- cjson库
- 源码方式引用,只有两个文件- 标准C89编写 - [cJSON 库项目地址](https://github.com/DaveGamble/cJSON)
- python -- 字符串和编码
字符串和编码 数字--文本 ascii(bg2312,shift_jis,eur_kr)--unicode--utf-8 ord(""),chr() 1 Python提供了ord ...