[Áú¹®]À̹ÌÁö À§¿¡´Â ¿Ö ¾È±×·ÁÁöÁ®? ¼Ò½º Á» ºÁÁÖ¼¼¿©.


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :ÀÓâ¿ø 2000³â 7¿ù 15ÀÏ 00:20:59

À̹ÌÁö(gifÆÄÀÏ)¸¦ ºÒ·¯¿Í¼­ À̹ÌÁö À§¿¡ ºÎ·¯½¬ È¿°ú¸¦ Á־ ±×¸²À» ±×¸®·Á´Âµ¥ À̹ÌÁöÀ§¿¡´Â ±×¸²ÀÌ ±×·ÁÁöÁö ¾Ê½À´Ï´Ù.
¾î¶»°Ô ÇؾßÇϳª¿©?
import java.awt.image.MemoryImageSource;
import java.applet.*;
import java.awt.*;


public class Test extends Applet
{
Image img;
Image offscreen;
Graphics total;
Image brushes[];
int brushIndex;
final int BRUSH_SIZE = 10;
final int BRUSH_AREA = BRUSH_SIZE*BRUSH_SIZE;
final int BLACK = 0;

public void init()
{
img = getImage(getDocumentBase(), getParameter("img0"));


int index, i, j;
int alpha;
MemoryImageSource mis;
offscreen = createImage(size().width, size().height);
total = offscreen.getGraphics();


index = 0;
int[][] sources = new int[1][BRUSH_AREA];
for(j = 0; j<BRUSH_SIZE; j++)
{
for(i=0; i<BRUSH_SIZE; i++)
{
alpha = getAlpha(i, j);
alpha <<= 24;
sources[BLACK][index] = 0x00000000 + alpha;
index++;
}
}
brushes = new Image[1];
mis = new MemoryImageSource(BRUSH_SIZE, BRUSH_SIZE, sources[0], 0, BRUSH_SIZE);
brushes[0] = createImage(mis);
}


public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(offscreen, 0, 0, this);
total.drawImage(img, 0, 0, this);
}
public boolean mouseDown(Event evtObj, int x, int y)
{
repaint();
return mouseDrag(evtObj, x, y);
}
public boolean mouseDrag(Event evtObj, int x, int y)
{
x -= BRUSH_SIZE/2;
y -= BRUSH_SIZE/2;
Image brush = brushes[0];
total.drawImage(brush, x, y, this);
repaint();
return true;
}
int getAlpha(int x, int y)
{
double deltaX = (double)(x - BRUSH_SIZE/2);
double deltaY = (double)(y - BRUSH_SIZE/2);
double distance = Math.sqrt(deltaX*deltaX + deltaY*deltaY);
double fracDistance = distance / (BRUSH_SIZE/2);
if(fracDistance > 1.0)
fracDistance = 1.0;
fracDistance = 1.0 - fracDistance;
fracDistance = Math.pow(fracDistance, 0.00001);
return (int)(255*fracDistance);
}
}


´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]