|
先自己把jar文件加载好 具体加载方法网上很多 我用的3.6可以直接加载
import processing.core.PApplet;
import java.util.ArrayList;
import java.util.Random;
public class graphics1 extends PApplet{
private static final long serialVersionUID = 1L;
float mx=0;
box[][] boxes=new box[80][60];
ArrayList list = new ArrayList();
Random rnd=new Random();
public void setup(){
frameRate(10);
size(800,600);
background(255);
for (int i=0 ;i<=79;i++){
for (int j=0 ;j<=59;j++){
boxes[i][j]=new box(i,j);
}
}}
public void draw(){
ArrayList list2 = new ArrayList();
if (list.size()!=0){
for (int i=0 ;imx){
boxes[array2[0]][array2[1]].isDraw=1;
list2.addAll(boxes[array2[0]][array2[1]].round());}
}
}
}else{noLoop();}
list=list2;
for (int i=0 ;i<=79;i++){
for (int j=0 ;j<=59;j++){
if(boxes[i][j].isDraw==1){boxes[i][j].draw(mx);}
}
}
mx+=0.1;
//noLoop();
}
public void mouseReleased(){
int[] drawbox ={(int)(mouseX/10),(int)(mouseY/10)};
list.add(drawbox);mx=0;
loop();
}
class box{
int x=0;
int y=0;
public int isDraw=0;
public box (int a,int b){
x=a;y=b;
}
public box(){}
public void draw(float mx){
if (isDraw==1){
int al=(int)mx*255;
fill(255,al,al);
rect((float)(x*10),(float)(y*10),10f,10f);
isDraw=2;}
}
public ArrayList round(){
ArrayList a=new ArrayList();
int[] a1={x+1,y};int[] a2={x,y+1};
int[] a3={x-1,y};int[] a4={x,y-1};
if (x>0){a.add(a3);}
if (x<79){a.add(a1);}
if (y>0){a.add(a4);}
if (y<59){a.add(a2);}
return a;
}
}
////////////////////////////////////////////////////
} |
评分
-
查看全部评分
|