抖动的沙粒/分子扩散模拟实验
管理员
"ui";
ui.statusBarColor("#ff000000");
ui.layout(
<frame id="bg" background="#000000">
<vertical>
<img id="ok"/>
<text id="text" color="#ffffff"/>
<linear>
 <button id="加" text="+" bg="#ff333333"/>
 <seekbar id="增量" progress="0" w="0"/>
 <button id="减" text="-" bg="#ff333333" margin="0 0 0 10"/>
</linear>
</vertical>
</frame>
);
沙粒增量=0;
importClass(android.graphics.Paint);
importClass(android.graphics.Canvas);
importClass(android.graphics.Bitmap);
横坐标=[540];
纵坐标=[540];
r=[255];
g=[0];
b=[0];
threads.start(function(){
var i=0;
var t1=1000,t2=0;
var bitmap =Bitmap.createBitmap(1080,1080,Bitmap.Config.ARGB_8888);

while(true){
var bitmap =Bitmap.createBitmap(1080,1080,Bitmap.Config.ARGB_8888);

var canvas = new Canvas(bitmap);
canvas.drawARGB(0,0,0,0);
var paint = new Paint();
/*
paint.setARGB(255,0,0,0);//白色画笔
paint.setStyle(Paint.Style.FILL);//空心样式  
canvas.drawCircle(540,540,510, paint);//绘制圆
*/
for(var i=0;i<横坐标.length;i++){
paint.setARGB(255,r[i],g[i],b[i]);//白色画笔
paint.setStyle(Paint.Style.FILL);//空心样式  
canvas.drawCircle(横坐标[i],纵坐标[i],1, paint);//绘制圆
横随机数=random(-1,1);
纵随机数=random(-1,1);
横坐标[i]+=横随机数;
纵坐标[i]+=纵随机数;
if(Math.sqrt(Math.pow(横坐标[i]-540,2)+Math.pow(纵坐标[i]-540,2))>499){
横坐标[i]-=横随机数;
纵坐标[i]-=纵随机数;
}
}

paint.setARGB(255,55,55,55);//白色画笔
paint.setStyle(Paint.Style.STROKE);//空心样式  
paint.setStrokeWidth(1);//边缘宽度  
canvas.drawCircle(540,540,500, paint);//绘制圆



canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.restore();
t1=new Date().getTime();

i=parseInt(1000/(t1-t2));
t2=t1;

ui.run(function(){
ui.ok.setImageBitmap(bitmap);
//ui.text.text(i+"");
});

}
});

ui.加.click(() => {
for(var i=0;i<沙粒增量;i++){
var 数量=横坐标.length;
var 横=0;var 纵=0;
while(Math.sqrt(Math.pow(横-540,2)+Math.pow(纵-540,2))>499){
横=random(0,1080);纵=random(0,1080);
}
横坐标[数量]=横;纵坐标[数量]=纵;
r[数量]=random(0,255);
g[数量]=random(0,255);
b[数量]=random(0,255);
}
});

ui.减.click(() => {
if(横坐标.length>沙粒增量){
横坐标.length=横坐标.length-沙粒增量;}else{
横坐标.length=0;
}
});

threads.start(function(){
while(true){
sleep(100);
沙粒增量=ui.增量.progress*10+1;
}
});
最后由 adman 编辑

@adman抖动的沙粒/分子扩散模拟实验 中说:

"ui";
ui.statusBarColor("#ff000000");
ui.layout(
<frame id="bg" background="#000000">
<vertical>
<img id="ok"/>
<text id="text" color="#ffffff"/>
<linear>
 <button id="加" text="+" bg="#ff333333"/>
 <seekbar id="增量" progress="0" w="0"/>
 <button id="减" text="-" bg="#ff333333" margin="0 0 0 10"/>
</linear>
</vertical>
</frame>
);
沙粒增量=0;
importClass(android.graphics.Paint);
importClass(android.graphics.Canvas);
importClass(android.graphics.Bitmap);
横坐标=[540];
纵坐标=[540];
r=[255];
g=[0];
b=[0];
threads.start(function(){
var i=0;
var t1=1000,t2=0;
var bitmap =Bitmap.createBitmap(1080,1080,Bitmap.Config.ARGB_8888);

while(true){
var bitmap =Bitmap.createBitmap(1080,1080,Bitmap.Config.ARGB_8888);

var canvas = new Canvas(bitmap);
canvas.drawARGB(0,0,0,0);
var paint = new Paint();
/*
paint.setARGB(255,0,0,0);//白色画笔
paint.setStyle(Paint.Style.FILL);//空心样式  
canvas.drawCircle(540,540,510, paint);//绘制圆
*/
for(var i=0;i<横坐标.length;i++){
paint.setARGB(255,r[i],g[i],b[i]);//白色画笔
paint.setStyle(Paint.Style.FILL);//空心样式  
canvas.drawCircle(横坐标[i],纵坐标[i],1, paint);//绘制圆
横随机数=random(-1,1);
纵随机数=random(-1,1);
横坐标[i]+=横随机数;
纵坐标[i]+=纵随机数;
if(Math.sqrt(Math.pow(横坐标[i]-540,2)+Math.pow(纵坐标[i]-540,2))>499){
横坐标[i]-=横随机数;
纵坐标[i]-=纵随机数;
}
}

paint.setARGB(255,55,55,55);//白色画笔
paint.setStyle(Paint.Style.STROKE);//空心样式  
paint.setStrokeWidth(1);//边缘宽度  
canvas.drawCircle(540,540,500, paint);//绘制圆



canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.restore();
t1=new Date().getTime();

i=parseInt(1000/(t1-t2));
t2=t1;

ui.run(function(){
ui.ok.setImageBitmap(bitmap);
//ui.text.text(i+"");
});

}
});

ui.加.click(() => {
for(var i=0;i<沙粒增量;i++){
var 数量=横坐标.length;
var 横=0;var 纵=0;
while(Math.sqrt(Math.pow(横-540,2)+Math.pow(纵-540,2))>499){
横=random(0,1080);纵=random(0,1080);
}
横坐标[数量]=横;纵坐标[数量]=纵;
r[数量]=random(0,255);
g[数量]=random(0,255);
b[数量]=random(0,255);
}***

});

ui.减.click(() => {
if(横坐标.length>沙粒增量){
横坐标.length=横坐标.length-沙粒增量;}else{
横坐标.length=0;
}
});

threads.start(function(){
while(true){
sleep(100);
沙粒增量=ui.增量.progress*10+1;
}
});

  • 4
    帖子
  • 1461
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待