加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
the_proportion_of_the_drawing.asy 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
jinnyang 提交于 2022-03-17 09:31 . 下载jamovi官网上的所有模块
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);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化