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 ...
随机推荐
- struts2.xml中所有constant详解--大全
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-/ ...
- python标准库介绍——1 os详解
== os 模块 == ``os`` 模块为许多操作系统函数提供了统一的接口. 这个模块中的大部分函数通过对应平台相关模块实现, 比如 ``posix`` 和 ``nt. os`` 模块会在第一次导入 ...
- 项目打成jar包
distributionManagement 为发布到本地参考的地址 repository 设置从本地maven库拉取jar包 <project xmlns:xsi="http://w ...
- 从github上下载项目到eclipse
第一步:把代码下载到本地的仓库中 到github后选择自己想下载的项目,拷贝它的URL,图示如下: 进入eclipse中 点击后如下: 继续 按照图片指示继续(大白菜next教程) fin ...
- unity update与fixedUpdate
update与渲染同步.fixedUpdate与物理同步. 在update中,speed要乘以Time.deltaTime.在fixedUpdate中,speed要乘以Time.fixedDeltaT ...
- 处理“位域”枚举类型变量的几个例子
所谓的位域就是说利用一个整形数字二进制下不同的标志位来使一个枚举变量可以记录多个信息. 例如现在有一个定义好的位域枚举: [Flags] public enum FlagEnum { 我是第一个=, ...
- [面试题] Find next higher number with same digits
Find next higher number with same digits. Example 1 : if num = 25468, o/p = 25486 Example 2 : if num ...
- ORACLE生成唯一标识函数
-- Create tablecreate table TAB_TEST( id VARCHAR2(40) not null, fxnum VARCHAR2(40)) ---------------- ...
- JS格式化数字保留两位小数点示例代码
格式化数字保留两位小数点实现的方法有很多,在接下来的文章中将为大家详细介绍下如何使用js来实现 a = a.toFixed(2);//保留2位但结果为一个String类型 a = parseFloat ...
- xilinx 官方技术资料
http://china.xilinx.com/support/index.html/content/xilinx/zh/supportNav/ip_documentation.html