Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Component;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.util.Random; import java.applet.Applet;
- import java.awt.image.*; import java.awt.*;
- public final class morboy extends java.applet.Applet implements Runnable
- {
- final int GC_Count=30; final int X_Size=256,Y_Size=256;
- IndexColorModel PAL; byte CPal[]=new byte[256]; int XY_Size,MX,MY;
- int Paint_Area[]; Thread Framer; int SinX[],SinY[]; int FlowY=0;
- int Radial_X[], Radial_Y[]; Random rand; double Angle; int Numbo;
- public String getAppletInfo() {
- return "Info?";
- }
- public void start() { Framer=new Thread(this); Framer.start(); }
- public void stop() { Framer.stop(); Framer=null; }
- public boolean imageUpdate(Image Img, int f, int x,
- int y, int w, int h) {return true;}
- public void paint(Graphics g) {
- g.drawImage(createImage(new MemoryImageSource(
- X_Size,Y_Size,PAL,Paint_Area,0,X_Size)
- ),0,0,X_Size,Y_Size,this);
- }
- public boolean mouseEnter(Event e, int x, int y) {
- IamAlive(); MX=x; MY=y; return true;}
- public boolean mouseExit(Event e, int x, int y) {
- showStatus("You have exited the Applet"); MX=MY=128; return true;}
- public boolean mouseMove(Event e, int x, int y) {
- MX=x; MY=y; return true;}
- public boolean mouseDown(Event e, int x, int y) {
- Numbo++; IamAlive(); RecalculateRadials(); return true;}
- public void init() { rand=new Random();
- for (int i=0;i<=127;i++) CPal[i]=(byte)(i*2);
- for (int i=128;i<=255;i++) CPal[i]=(byte)((255-i)*2);
- PAL=new IndexColorModel(8,256,CPal,CPal,CPal);
- XY_Size=X_Size*Y_Size; Paint_Area=new int[XY_Size];
- Radial_X=new int[XY_Size*4]; Radial_Y=new int[XY_Size*4];
- SinX=new int[X_Size]; SinY=new int[Y_Size];
- for (int i=0;i<X_Size;i++)
- {
- SinX[i]=(int)( (Math.sin(Math.PI*i*4/X_Size)+1) *63);
- }
- for (int i=0;i<Y_Size;i++)
- {
- SinY[i]=(int)( (Math.sin(Math.PI*i*2/Y_Size)+1) *127);
- }
- MX=MY=128;
- RecalculateAngle();
- Numbo=1;
- RecalculateRadials();
- }
- public void run() {
- int Loop; while (true) {
- DrawPlasma1();
- paint(getGraphics());
- System.gc();
- }
- }
- void RecalculateAngle() {
- Angle=(double)(Math.abs(rand.nextInt()) % 20)/2+0.5; // SetUp angler
- }
- void RecalculateRadials() {
- double aa=(X_Size)*Angle/2/Math.PI;
- int x = 0,p=0, r=0;
- for (int y=0; y< 256; y++)
- {
- for(x=0;x<256;x++)
- {
- r=Math.min((int)Math.sqrt(x*x+y*y),Y_Size);
- double a= (x==0)?Math.PI/2:Math.atan((double)y/(double)x);
- p=(Y_Size+y)*2*X_Size+(X_Size+x); Radial_Y[p]=r;
- Radial_X[p]=(int)(a*aa) % X_Size; // 90 -> 0 [4]
- p=(Y_Size-y)*2*X_Size+(X_Size+x); Radial_Y[p]=r;
- Radial_X[p]=(int)((2*Math.PI-a)*aa) % X_Size; // 270 -> 360 [1]
- p=(Y_Size-y)*2*X_Size+(X_Size-x); Radial_Y[p]=r; // 270 -> 180 [2]
- Radial_X[p]=(int)((Math.PI+a)*aa) % X_Size;
- p=(Y_Size+y)*2*X_Size+(X_Size-x); Radial_Y[p]=r;
- Radial_X[p]=(int)((Math.PI-a)*aa) % X_Size; // 90 -> 180 [3]
- }
- }
- }
- void DrawPlasma1() { int xx,yy,x,p=0,pp;
- pp=(~MX & 0xFF)+((~MY & 0xFF) << 9);
- for (x=0;x<256;x++)
- for (int y=0;y<256; y++)
- {
- xx=Radial_X[pp]; yy=Radial_Y[pp++];
- Paint_Area[p++]=SinX[(xx+SinX[(xx+SinY[y]) & 0xFF]+SinY[(yy+SinX[(xx+FlowY) & 0xFF])& 0xFF]+FlowY) & 0xFF];
- }pp+=0x100;
- }
- void DrawPlasma6() { int xx,yy,x,p=0,pp;
- pp=(~MX & 0xFF)+((~MY & 0xFF) << 9);
- for (x=0;x<256;x++)
- for (int y=0;y<256; y++)
- {
- xx=Radial_X[pp]; yy=Radial_Y[pp++];
- Paint_Area[p++]=SinX[(xx+SinX[(SinX[(SinX[xx]+SinY[y]+FlowY) & 0xFF]+SinY[(SinX[xx]+yy) & 0xFF]) &0xFF]+SinY[(yy+SinX[(SinX[xx]+FlowY) &0xFF]) &0xFF]+FlowY) & 0xFF];
- }
- pp+=0x100;
- }
- void DrawPlasma() { int xx,yy,x,y,p=0,pp;
- pp=(~MX & 0xFF)+((~MY & 0xFF) << 9);
- for (x=0;x<256; x++)
- for (y=0;y<256;y++) {
- xx=Radial_X[pp]; yy=Radial_Y[pp++];
- Paint_Area[p++]=SinY[(yy+SinY[yy & 0xFF]+SinX[(xx+SinY[(yy+FlowY) & 0xFF]) & 0xFF] +FlowY) & 0xFF];
- } pp+=0x100; }
- void IamAlive() {
- showStatus("You have entered the applet");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement