[HTML]纯文本查看 复制代码
//运用HTML5绘制规范五星红旗
varcanva=document.getElementById”canvas”;
varcontext=canvas.getContext\’2d\’;
varwidth=canvas.width;
varheight=width*2/3;
varw=width/30;//小网格的宽
context.fillStyl=”red”;
context.fillRect0,0,width,height;
varmaxR=0.15,minR=0.05;//
varmaxX=0.25,maxY=0.25;//大五星的地位
varminX=[0.50,0.60,0.60,0.50];
varminY=[0.10,0.20,0.35,0.45];
//画大 ☆
varox=height*maxX,oy=height*maxY;
create5四季题材starcontext,ox,oy,height*maxR,”#ff0″,0;//绘制五角星
//画小
forvaridx=0;idx<4;idx++短片题材{
varsx=minX[idx]*height,sy=minY[idx]*height;
vartheta=Math.atanoy-sy/ox-sx;
create5starcontext,sx,sy,height*minR,”#ff0″,-Math.PI/2+theta;
//绘制五角星
/**
*创立一个五角星外形.该五角星的中央坐标为(sx,sy,中央到极点的间隔为radius,rotate=0时一个顶影视题材点在对称轴上
*rotate:绕对称轴旋学生题材转rotat弧度
functioncreate5starcontext,sx,sy,radius,color,rotato{
context.sav;
context.fillStyl=color;
context.translsx,sy;//挪动坐标原点
context.rotMath.PI+rotato;//旋转的
context.beginPath;//创立途径
varx=Math.sin0;
vary=Math.co0;
vardig=Math.PI/5*4;
forvari=0;i<5;i++{//画五角星的五条边
varx=Math.sini*dig;
vary=Math.coi*dig;
context.lineTox*radius,y*radiu;
context.closePath;
context.strok;
context.fil;
context.restor;
原文链接:https://blog.csdn.net/weixin_42335570/article/details/117133445?ops_request_misc=%视频题材257B%2522request%255Fid%2522%253A %2522166856496116782瀑布题材388081138%2522%252C%2522scm%2522%253A %252220140713.130102334.pc%255Fblog.%2522%257D&request_id=166856496116782388081138&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-6-117133445-null-null.nonecase&utm_term=%E9%A 2%98%E6%9D%90
未经允许不得转载:题材网 » 五星红旗的编程代码C言语,规范五星红旗html转自网上)