代码拉取完成,页面将自动刷新
settings.outformat = "svg";
guide pentagram(pair c,real r,real ang){
/**
@param c the location of pentagram where you want to draw.
@param r the radius of the outer circle.
@param ang the angle at which the graph rotates counterclockwise.
@return the path without rendering(guide object).
*/
guide g;
real outer_r = r;
real inner_r = 0.382*r;
for(int i=0;i<10;++i){
// calculate the coordinate of the next point
pair tmp = (0,0) + c;
if(i%2==0){
tmp = (0,outer_r) + c;
}else{
tmp = (0,inner_r) + c;
}
g = g--rotate(36*i,c)*tmp; // connect each other
}
g = g--cycle;
return(rotate(ang,c)*g);
}
//set scale
unitsize(100,100);
//draw backgroud
real width = 3,height=2;
path flag_outer_line=(0,0)--(0,height)--(width,height)--(width,0)--cycle;
filldraw(flag_outer_line,red,red);
// draw the greatest star
path big_star = pentagram((width/6,3*height/4),3*height/20,0);
filldraw(big_star,yellow,yellow);
// draw the remaining star
path star_1 = pentagram((width/3,9*height/10),height/20,120.964);
path star_2 = pentagram((2*width/5,4*height/5),height/20,98.13);
path star_3 = pentagram((2*width/5,13*height/20),height/20,74.055);
path star_4 = pentagram((width/3,11*height/20),height/20,51.34);
filldraw(star_1,yellow,yellow);
filldraw(star_2,yellow,yellow);
filldraw(star_3,yellow,yellow);
filldraw(star_4,yellow,yellow);
/** Check the angle orientation of the each star.**/
draw((width/6,3*height/4)--(width/3,9*height/10),white);
draw((width/6,3*height/4)--(2*width/5,4*height/5),white);
draw((width/6,3*height/4)--(2*width/5,13*height/20),white);
draw((width/6,3*height/4)--(width/3,11*height/20),white);
draw((width/2,0)--(width/2,height),gray);
draw((0,height/2)--(width,height/2),gray);
for(int i=1;i<15;++i){
draw((i*width/30,height/2)--(i*width/30,height),blue);
}
for(int i=11;i<20;++i){
draw((0,i*height/20)--(width/2,i*height/20),blue);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。