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 如果没有报错,应该是安装好了~ 如果报错找不到模块,很可能是安装版本的问 ...
随机推荐
- DNS与NS、NS记录
DNS:人们习惯记忆域名,但机器间互相只认IP地址,域名与IP地址之间是一一对应的,它们之间的转换工作称为域名解析,域名解析需要由专门的域名解析服务器来完成,整个过程是自动进行的. 当你的网站制作完成 ...
- Html中meta标签详解--以前经常忽略的
W3School介绍:http://www.w3school.com.cn/html5/html5_meta.asp meta是用来在HTML文档中模拟HTTP协议的响应头报文. meta 标签的用处 ...
- 机器学习(4): KNN 算法
1. 综述 1.1 Cover和Hart在1968年提出了最初的邻近算法 1.2 分类(classification)算法 1.3 输入基于实例的学习(instance- ...
- Django ORM 数据库操作
比较有用 转自 http://blog.csdn.net/fgf00/article/details/53678205 一.DjangoORM 创建基本类型及生成数据库表结构 1.简介 2.创建数据库 ...
- nginx是以多进程的方式来工作的
nginx是以多进程的方式来工作的. nginx在启动后,会有一个master进程和多个worker进程. master进程主要用来管理worker进程: 包含: 1.接收来自外界的信号,向各work ...
- [na]出口选路pbr小实验视频
什么是策略路由? 一般都是部署在出口路由器,用于路径强制分发的, 优先级高于路由表. 策略路由小实验视频 这个是读书时候录的一个策略路由小实验
- android笔记一 控件属性
<?xml version = "1.0" encoding = "utf-8"?> <LinearLayout xmlns:android= ...
- Oracle PLSQL Demo - 03.流程判断[IF ELEIF ELSE]
declare v_job ) := 'Programmer'; v_sal number; begin if v_job = 'Programmer' then v_sal :; elsif v_j ...
- js 学习的地址;
1.https://github.com/windiest/Front-end-tutorial 2.http://www.w3school.com.cn/tags/html_ref_eve ...
- C++构造函数的调用
C++中类的构造函数的调用有四种形式 C++中对象的实例化有四种情况: 1.调用默认构造函数. 2.隐式调用构造函数 3.显示调用构造函数 4.使用new操作符 如图所示,前三种在对象的作用域之外就会 ...