e578. Setting the Clipping Area with a Shape
This example demonstrates how to set a clipping area using a shape. The example sets an oval for the clipping area and then draws and image. Only those pixels of the image that fall within the oval are displayed.
// See e575 The Quintessential Drawing Program
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g; // Create an oval shape that's as large as the component
float fx = 0;
float fy = 0;
float fw = getSize().width-1;
float fh = getSize().height-1;
Shape shape = new java.awt.geom.Ellipse2D.Float(fx, fy, fw, fh); // Set the clipping area
g2d.setClip(shape); // Draw an image
int x = 0;
int y = 0;
g2d.drawImage(image, x, y, this);
}
| Related Examples |
e578. Setting the Clipping Area with a Shape的更多相关文章
- 动态计算area位置
window.onresize = adjuest; function adjuest(){ var picw = $(".imgbox img").width(); var pi ...
- YTU 2915: Shape系列-1
2915: Shape系列-1 时间限制: 1 Sec 内存限制: 128 MB 提交: 283 解决: 221 题目描述 小强开始迷恋彩色的Shape,于是决定做一个Shape类.Shape类有 ...
- area热点区域
<area>标记:主要用于图像地图,通过该标记可以在图像地图中设定作用区域(又称为热点),这样当用户的鼠标移到指定的作用区域点击时,会自动链接到预先设定好的页面.其基本语法结构如下: &l ...
- area标签的使用,图片中某一个部分可以点击跳转,太阳系中点击某个行星查看具体信息
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- html|Area
http://tomys.win/ HTML图片热区Area map的用法只是在上学的时候学习到过,在实际工作中一直没用过,如果 不是这次紧急任务,可能永远都不会想起这个功能.在一些特殊的html ...
- Using SetWindowRgn
Using SetWindowRgn Home Back To Tips Page Introduction There are lots of interesting reasons for cre ...
- PHP7函数大全(4553个函数)
转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...
- Paths_Quartz2D
Paths中的几个重要元素 Points void CGContextMoveToPoint ( CGContextRef c, CGFloat x, CGFloat y ); 指定 ...
- Paths(转载)
Paths中的几个重要元素 Points void CGContextMoveToPoint ( CGContextRef c, CGFloat x, CGFloat y ); 指定一个点成为curr ...
随机推荐
- Python exp() 函数
描述 exp() 方法返回x的指数,ex. 语法 以下是 exp() 方法的语法: import math math.exp( x ) 注意:exp()是不能直接访问的,需要导入 math 模块,通过 ...
- PHP Client for Mysql Binlog
PHP解析MySQL Binlog,依赖于mysql-replication-listener库 详见:https://github.com/bullsoft/php-binlog Install M ...
- ERROR: JDWP Unable to get JNI 1.2 environment的错误解决方法
在用java编程的时候,在debug模式下偶尔会出现下面的错误,jdk1.6.0-rc1: ERROR: JDWP Unable to get JNI 1.2 environment, jvm-> ...
- Hadoop: Setup Maven project for MapReduce in 5mn
Hadoop: Setup Maven project for MapReduce in 5mn 25 MAY 2013 / ANTOINE AMEND I am sure I am not the ...
- oracle 连接字符串备份
Oracle XE 标准连接 Oracle XE(或者"Oracle Database 10g Express Edition")是一个简单免费发布的版本. 以下是语法格式: Dr ...
- Nginx用户认证配置方法详解(域名/目录)
Nginx超级强大它可以单独为一个域名设置用户认证,方法也很简单我们只要生成用户认证的用户名和密码,然后再Nginx添加auth认证配置即可 Nginx可以为某一个域名单独加用户认证,具体做法如下: ...
- 批处理学习笔记2 - 编写批处理的for循环
批处理中的for循环集成的功能比较多,可以直接对文件操作. ====================================================================== ...
- CCCallFunc和CCSequence
class CC_DLL CCCallFunc : public CCActionInstant //<NSCopying> void Issue1305_2::onEnter() { A ...
- jquery+ashx checkbox 单选判断是否true 和 false 传值操作
示例图: html标签代码: <p></p> <label for="checkbox" style="float:left" & ...
- ny655 光棍的yy 大数处理
光棍的yy 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 yy经常遇见一个奇怪的事情,每当他看时间的时候总会看见11:11,这个很纠结啊. 现在给你m个1,你可以把2个 ...