/* 鳴門 ImageFilter Ver 0.10 */ /* */ /* */ /* by Atsushi 98/4/9 */ package net.antun.lib.awt.image; import java.awt.Dimension; import java.awt.image.ColorModel; public class NaltImageFilter extends SinglepassImageFilter { /* --- Field --- */ private int width,height; private double amplitude; /* --- Constructor --- */ public NaltImageFilter(double amplitude) { this.amplitude=amplitude; } /* --- フィルタリング --- */ public void setDimensions(int width,int height) { double r; super.setDimensions(width,height); r=Math.sqrt((width/2.0)*(width/2.0)+(height/2.0)*(height/2.0)); this.width =width +(int)(r-width /2.0)*2; this.height=height+(int)(r-height/2.0)*2; consumer.setDimensions(this.width,this.height); } protected void filterImage() { double r,th; int xx,yy,cx,cy; int p[]; p=new int[width]; cx=width /2; cy=height/2; for (int y=0;y<=height-1;y++) { for (int x=0;x<=width-1;x++) { th=Math.atan2(y-cy,x-cx); r=Math.sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy)); xx=(int)(Math.cos(th+amplitude/r)*r)+originalSize.width /2; yy=(int)(Math.sin(th+amplitude/r)*r)+originalSize.height/2; if (0<=xx && xx