马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- <P>void setup(){
- size(500,500);
- background(255);
- smooth();
- }</P>
- <P>void draw(){
- translate(100,100);
- strokeWeight(2);
- fill(200);
- star(200);</P>
- <P>}</P>
- <P>void star(float R){
- float r = R*sin(radians(18))/cos(radians(36));
- float[] x = new float[11];
- float[] y = new float[11];
- for(int i=0;i<10;i++){
- if(i%2==0){
- x[i] = R*(cos(radians(72*i/2)));
- y[i] = R*(sin(radians(72*i/2)));
- }
- else{
- x[i] = r*(cos(radians(72*i/2)));
- y[i] = r*(sin(radians(72*i/2)));
- }
- }
- x[10] = x[0];
- y[10] = y[0];</P>
- <P>beginShape();
- for(int i=0;i<11;i++){
- vertex(x[i],y[i]);
- }
- endShape();
- }</P>
复制代码
|