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 ...
随机推荐
- Spring注解方式配置说明
1.<context:annotation-config/>与<context:component-scan base-package=”XX.XX”/> 在基于主机方式配置S ...
- VLOG丨树莓派Raspberry Pi 3安装PLEX并挂载USB硬盘打造最牛的微型家庭影音服务器2018
视频介绍 树莓派3安装目前最流行的PLEX服务器,实现既能最大限度降低功耗,也能随时随地观看分享影片. 一.在树莓派下安装PLEX媒体服务器 1.在终端,将你的树莓派更新至最新 sudo apt up ...
- 深入Javascript中apply、call、bind
最近在看一下node package的源码,发现很多里面都包含了function这个对象的apply.call.bind这三个方法,于是想拿出来再看看.. apply.call 在 javascrip ...
- cocos2dx 3.x避免空customCommand
1,导致性能悲剧的写法: class A:public CCNode{ public: A(){ m_sprite=NULL; m_isDrawDebug=false; } virtual~A(){} ...
- Sublime Text 3 快捷鍵
/*On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bind ...
- RAID卡 BBU Learn Cycle周期的影响
背景 最近遇到有些带MegaSAS RAID卡的服务器,在业务高峰时突然IO负载飚升得很高,IO性能急剧下降,查了日志及各种设置最后才发现是RAID卡的Cache写策略由 WriteBack变成Wri ...
- #pragma GCC system_header用法
在看公司公共库的头文件中发现了:#pragma GCC system_header一行,以前没有见过这种用法,在网上查了一下,解释如下: 从#pragma GCC system_header直到文件结 ...
- ny509 因子和阶乘
因子和阶乘 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 给你一个正整数n,把n!=1x2x3x.....xn分解成素因子相乘的形式,并从小到大输出每个素因子的指数 ...
- hdoj1114 Piggy-Bank
Piggy-Bank Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- 如何做一个像btbook.net这样的搜片神器?
这几天btbook.net这个搜片神器网站火了, 让我这个无工作的人, 也想做一个出来, 不然时间不好打发, 本人的草稿站: fastbot.me (刚发布几个小时, 体验等几天再做) 现在说说这种搜 ...