馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
package com.example.ifs;
import android.R.color;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
public class IFS extends Activity {
float x,y,x1,y1,ra,ra1;
int num;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new DrawView(this));
}
public class DrawView extends View{
public DrawView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setAntiAlias(true);
paint.setStrokeWidth(10);
paint.setStyle(Paint.Style.FILL);
while(num<20000){
ra=(int)(Math.random()*100);
ra1=(float) (ra*0.01);
if(ra1<=0.01){
x1=(float)0.0;
y1=(float)0.16*y;
x=x1;
y=y1;
canvas.drawPoint(x+100, y+100, paint);
}
else if(ra1<=0.86){
x1=(float)0.85*x+(float)0.04*y;
y1=(float)-0.04*x+(float)0.85*y+(float)1.6;
x=x1;
y=y1;
canvas.drawPoint(x+100, y+100, paint);
}
else if(ra1<=0.93){
x1=(float)0.2*x+(float)0.26*y;
y1=(float)-0.23*x+(float)0.22*y+(float)1.6;
x=x1;
y=y1;
canvas.drawPoint(x+100, y+100, paint);
}
else{
x1=(float)-0.15*x+(float)0.28*y;
y1=(float)-0.26*x+(float)0.24*y+(float)0.44;
x=x1;
y=y1;
canvas.drawPoint(x+100, y+100, paint);
}
num++;
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_ifs, menu);
return true;
}
}
以上是我看著http://163.13.111.54/high_school/examples/fern.f 這個 大致摸索出來...
感覺錯很大 可是又不知道哪裡錯((我看不懂他的程式 運算是勉強
我想要寫 IFS 蕨類碎形的程式
可是怎麼寫 他都是出現一坨... |