【成图】

 

【Canvas与徽章】国庆75周年徽章_徽章

【Canvas与徽章】国庆75周年徽章_Canvas_02

【Canvas与徽章】国庆75周年徽章_徽章_03

【Canvas与徽章】国庆75周年徽章_徽章_04

【代码】

<!DOCTYPE html>
<html lang="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<head>
     <title>金边黑盾75周年</title>
     <style type="text/css">
     .centerlize{
        margin:0 auto;
        width:1200px;
     }
     </style>
     </head>

     <body onload="init();">
        <div class="centerlize">
            <canvas id="myCanvas" width="12px" height="12px" style="border:1px dotted black;">
                如果看到这段文字说您的浏览器尚不支持HTML5 Canvas,请更换浏览器再试.
            </canvas>
        </div>
     </body>
</html>
<script type="text/javascript">
<!--
/*****************************************************************
* 将全体代码(从<!DOCTYPE到script>)拷贝下来,粘贴到文本编辑器中,
* 另存为.html文件,再用chrome浏览器打开,就能看到实现效果。
******************************************************************/

// canvas的绘图环境
var ctx;

// 高宽
const WIDTH=512;
const HEIGHT=512;

// 舞台对象
var stage;

//-------------------------------
// 初始化
//-------------------------------
function init(){
    // 获得canvas对象
    var canvas=document.getElementById('myCanvas');  
    canvas.width=WIDTH;
    canvas.height=HEIGHT;

    // 初始化canvas的绘图环境
    ctx=canvas.getContext('2d');  
    ctx.translate(WIDTH/2,HEIGHT/2);// 原点平移

    // 准备
    stage=new Stage();    
    stage.init();

    // 开幕
    animate();
}

// 播放动画
function animate(){    
    stage.update();    
    stage.paintBg(ctx);
    stage.paintFg(ctx);     

    // 循环
    if(true){
        //sleep(100);
        window.requestAnimationFrame(animate);   
    }
}

// 舞台类
function Stage(){
    // 初始化
    this.init=function(){
        
    }

    // 更新
    this.update=function(){    
        
    }

    // 画背景
    this.paintBg=function(ctx){
        ctx.clearRect(-WIDTH/2,-HEIGHT/2,WIDTH,HEIGHT);// 清屏    
    }

    // 画前景
    this.paintFg=function(ctx){
        // 底色
        ctx.save();
        ctx.fillStyle = "white";
        ctx.fillRect(-WIDTH/2,-HEIGHT/2,WIDTH,HEIGHT);
        ctx.restore();

        const R=210;// 基准尺寸

        // 最外层金边
        ctx.save();
        var r=R*1.00;
        var gnt1=ctx.createLinearGradient(0,-r,0,r);
        gnt1.addColorStop(0,  "rgb(238,230,165)");
        gnt1.addColorStop(0.25,"rgb(222,183,62)");
        gnt1.addColorStop(0.5,"rgb(255,255,190)");
        gnt1.addColorStop(0.6,"rgb(152,97,33)");
        gnt1.addColorStop(0.8,"rgb(252,238,165)");
        gnt1.addColorStop(1,  "rgb(217,173,74)");    
        ctx.fillStyle=gnt1;
        ctx.beginPath();
        ctx.arc(0,0,r,0,Math.PI*2,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第一层上半圈渐变外框
        ctx.save();
        var ro=R*0.99;// outer radius
        var ri=R*0.91;// inner radius
        var gnt=ctx.createLinearGradient(0,-ro,0,0);
        gnt.addColorStop(0,  "rgb(255,254,250)");
        gnt.addColorStop(0.5,"rgb(253,221,112)");
        gnt.addColorStop(0.9,"rgb(254,235,192)");
        gnt.addColorStop(1,"rgb(254,222,145)");
        ctx.fillStyle=gnt;
        ctx.beginPath();
        ctx.moveTo(ri,0);
        ctx.lineTo(ro,0);
        ctx.arc(0,0,ro,0,-Math.PI,true);
        ctx.lineTo(-ri,0);
        ctx.arc(0,0,ri,-Math.PI,0,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第一层下半圈渐变外框
        ctx.save();
        var ro=R*0.99;// outer radius
        var ri=R*0.91;// inner radius
        var gnt=ctx.createLinearGradient(0,0,0,ro);
        gnt.addColorStop(0,  "rgb(254,222,145)");
        gnt.addColorStop(0.10,  "rgb(136,60,0)");
        gnt.addColorStop(0.5,"rgb(245,206,15)");
        gnt.addColorStop(1,"rgb(255,233,165)");
        ctx.fillStyle=gnt;
        ctx.beginPath();
        ctx.moveTo(ri,0);
        ctx.lineTo(ro,0);
        ctx.arc(0,0,ro,0,Math.PI,false);
        ctx.lineTo(-ri,0);
        ctx.arc(0,0,ri,Math.PI,0,true);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第二层黑圈
        ctx.save();
        var r=R*0.90;
        ctx.fillStyle="black";
        ctx.beginPath();
        ctx.arc(0,0,r,0,Math.PI*2,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第三层金窄圈
        ctx.save();
        var ro=R*0.88;// outer radius
        var ri=R*0.86;// inner radius
        var gnt=ctx.createLinearGradient(0,-ro,0,0);
        gnt.addColorStop(0,  "rgb(254,252,239)");
        gnt.addColorStop(0.5,"rgb(251,218,125)");
        gnt.addColorStop(0.9,"rgb(255,230,165)");
        gnt.addColorStop(1,"rgb(90,17,0)");
        ctx.fillStyle=gnt;
        ctx.beginPath();
        ctx.moveTo(ri,0);
        ctx.lineTo(ro,0);
        ctx.arc(0,0,ro,0,-Math.PI,true);
        ctx.lineTo(-ri,0);
        ctx.arc(0,0,ri,-Math.PI,0,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第2层下半圈渐变外框
        ctx.save();
        var ro=R*0.88;// outer radius
        var ri=R*0.86;// inner radius
        var gnt=ctx.createLinearGradient(0,0,0,ro);
        gnt.addColorStop(0,  "rgb(90,17,0)");
        gnt.addColorStop(0.5,"rgb(200,139,0)");
        gnt.addColorStop(1,"rgb(255,233,165)");
        ctx.fillStyle=gnt;
        ctx.beginPath();
        ctx.moveTo(ri,0);
        ctx.lineTo(ro,0);
        ctx.arc(0,0,ro,0,Math.PI,false);
        ctx.lineTo(-ri,0);
        ctx.arc(0,0,ri,Math.PI,0,true);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第4层黑圈
        ctx.save();
        var r=R*0.86;
        ctx.fillStyle="black";
        ctx.beginPath();
        ctx.arc(0,0,r,0,Math.PI*2,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 橄榄枝
        ctx.save();
        
        ctx.shadowOffsetY=2; // 设置阴影
        ctx.shadowColor="grey";
        ctx.shadowBlur=1;

        var r=R*0.75;
        var gnt=ctx.createLinearGradient(0,-r,0,r);
        gnt.addColorStop(0,"rgb(255,254,237)");
        gnt.addColorStop(0.25,"rgb(255,221,129)");
        gnt.addColorStop(0.5,"rgb(254,235,192)");
        gnt.addColorStop(0.6,"rgb(102,39,4)");
        gnt.addColorStop(0.75,"rgb(254,185,3)");
        gnt.addColorStop(1,"rgb(247,222,129)");
        var N=36;
        // 左橄榄枝
        drawLeftOliver(ctx,0,0,r,N,Math.PI/2-Math.PI/48,Math.PI/2*3-Math.PI/8,Math.PI/6,Math.PI/4,gnt);
        // 右橄榄枝
        drawRightOliver(ctx,0,0,r,N,-Math.PI/2+Math.PI/8,Math.PI/2+Math.PI/48,Math.PI/6,Math.PI/4,gnt);
        ctx.restore();

        // 上方三颗星
        var ANGLE=Math.PI/7;// 张角
        var N=3;
        var PART=ANGLE/(N-1);
        var r=R*0.75;
        for(var i=0;i<N;i++){
            var theta=-Math.PI/2-ANGLE/2+PART*i;
            var a=createPt(r*Math.cos(theta),r*Math.sin(theta));
            ctx.save();
            ctx.translate(a.x,a.y);
            ctx.rotate(theta+Math.PI/2);
            ctx.strokeStyle="rgb(254,185,3)";
            ctx.fillStyle="gold";
            draw5Star(ctx,0,0,r/16);
            ctx.fill();
            ctx.stroke();
            ctx.restore();
        }

        // 左上弯月玻璃光
        ctx.save();
        var r=R*0.86;
        var alpha=Math.asin(0.75);
        var beta=Math.PI-2*alpha;
        var gama=Math.PI/2-alpha;
        var o1=createPt(r/Math.sqrt(2),r/Math.sqrt(2));
        ctx.fillStyle="rgba(190,190,190,0.3)"; // 填充半透明色
        ctx.beginPath();
        ctx.arc(0,0,r,Math.PI/4*5+beta,Math.PI/4*5-beta,true);
        ctx.arc(o1.x,o1.y,r*1.5,Math.PI/4*5-gama,Math.PI/4*5+gama,false);
        ctx.closePath();
        ctx.fill();    
        ctx.restore();

        // 第5层黑圈
        ctx.save();
        var r=R*0.60;
        ctx.fillStyle="black";
        ctx.beginPath();
        ctx.arc(0,0,r,0,Math.PI*2,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第6层上半圈渐变外框
        ctx.save();
        var ro=R*0.63;// outer radius
        var ri=R*0.50;// inner radius
        var gnt=ctx.createLinearGradient(0,-ro,0,0);
        gnt.addColorStop(0,  "rgb(255,254,250)");
        gnt.addColorStop(0.5,"rgb(253,221,112)");
        gnt.addColorStop(0.9,"rgb(254,235,192)");
        gnt.addColorStop(1,"rgb(254,222,145)");
        ctx.fillStyle=gnt;
        ctx.beginPath();
        ctx.moveTo(ri,0);
        ctx.lineTo(ro,0);
        ctx.arc(0,0,ro,0,-Math.PI,true);
        ctx.lineTo(-ri,0);
        ctx.arc(0,0,ri,-Math.PI,0,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 第6层下半圈渐变外框
        ctx.save();
        var ro=R*0.63;// outer radius
        var ri=R*0.50;// inner radius
        var gnt=ctx.createLinearGradient(0,0,0,ro);
        gnt.addColorStop(0,  "rgb(254,222,145)");
        gnt.addColorStop(0.10,  "rgb(136,60,0)");
        gnt.addColorStop(0.5,"rgb(245,206,15)");
        gnt.addColorStop(1,"rgb(255,233,165)");
        ctx.fillStyle=gnt;
        ctx.beginPath();
        ctx.moveTo(ri,0);
        ctx.lineTo(ro,0);
        ctx.arc(0,0,ro,0,Math.PI,false);
        ctx.lineTo(-ri,0);
        ctx.arc(0,0,ri,Math.PI,0,true);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 最外层金边
        ctx.save();
        var r=R*0.50;
        var gnt1=ctx.createLinearGradient(0,-r,0,r);
        gnt1.addColorStop(0,  "rgb(238,230,165)");
        gnt1.addColorStop(0.25,"rgb(222,183,62)");
        gnt1.addColorStop(0.5,"rgb(255,255,190)");
        gnt1.addColorStop(0.6,"rgb(152,97,33)");
        gnt1.addColorStop(0.8,"rgb(252,238,165)");
        gnt1.addColorStop(1,  "rgb(217,173,74)");    
        ctx.fillStyle=gnt1;
        ctx.beginPath();
        ctx.arc(0,0,r,0,Math.PI*2,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 蓝黑辐射渐变底
        ctx.save();        
        var r=R*0.49;
        var gnt=ctx.createRadialGradient(0,0,0,0,0,r);
        gnt.addColorStop(0,"rgb(22,74,159)");
        gnt.addColorStop(1,"rgb(7,4,20)");
        ctx.fillStyle=gnt;
        ctx.beginPath();
        ctx.arc(0,0,r,0,Math.PI*2,false);
        ctx.closePath();
        ctx.fill();
        ctx.restore();

        // 75
        ctx.save();
        r=R*0.49;
        var x=0,y=r/11*7;
        var word="75";
        ctx.textBaseline="bottom";
        ctx.textAlign="center";
        ctx.font = r/0.8+"px consolas";
        ctx.fillStyle=gnt1;
        ctx.fillText(word,x,y);
        ctx.strokeStyle="gold";
        ctx.strokeText(word,x,y);
        ctx.restore();

        // YEARS
        ctx.save();
        r=R*0.49;
        var x=0,y=r/1.4;
        var word="YEARS";
        ctx.textBaseline="bottom";
        ctx.textAlign="center";
        ctx.font = r/3.5+"px consolas";
        ctx.fillStyle="rgb(68,41,11)";
        ctx.fillText(word,x,y);
        ctx.strokeStyle="gold";
        ctx.strokeText(word,x,y);
        ctx.restore();

        // 中心上方波浪玻璃光
        ctx.save();
        var r=R*0.49;        
        ctx.fillStyle=gnt;
        ctx.fillStyle="rgba(210,0,210,0.2)"; // 填充半透明紫色
        
        ctx.beginPath();
        ctx.arc(0,0,r,Math.PI,Math.PI*2,false);
        ctx.quadraticCurveTo(r/2,-r/4,0,0);
        ctx.quadraticCurveTo(-r/2,r/4,-r,0);
        ctx.fill();
        ctx.restore();


        writeText(ctx,WIDTH/2-30,HEIGHT/2-5,"逆火制图","8px consolas","lightgrey");// 版权
    }
}

/*----------------------------------------------------------
函数:画顺时针橄榄枝
x:横坐标
y:纵坐标
r:橄榄枝中心半径
n:叶片对数
start:起始角度
end:中止角度
alpha: 叶片中线到圆弧的角度
beta:叶片中线到圆弧的角度
color:叶片颜色
----------------------------------------------------------*/
function drawLeftOliver(ctx,x,y,r,n,start,end,alpha,beta,color){
    const R=r;                // 橄榄枝中心半径
    var   N=n;                // 有N对叶片    
    const START=start;        // 起始角度
    const END=end;            // 中止角度
    const STEP=(END-START)/N;// 步长        
    const ALPHA=alpha;        // 叶片中线到圆弧的角度
    const L=R/8;            // 叶片长度
    const BETA=beta;        // 叶片中线到圆弧的角度
    
    ctx.save();    
    ctx.translate(x,y);
    ctx.rotate(STEP);
    ctx.lineWidth=1;
    ctx.strokeStyle=color;

    // 画中心圈
    ctx.beginPath();
    for(var i=0;i<N;i++){
        var theta=START+STEP*i;
        var r=R;
        var a=createPt(r*Math.cos(theta),r*Math.sin(theta));
        ctx.lineTo(a.x,a.y);            
    }
    ctx.stroke();

    
    // 画外侧叶子
    for(var i=0;i<N;i++){
        var theta=START+STEP*i;
        var r=R;
        var a=createPt(r*Math.cos(theta),r*Math.sin(theta));
        
        var ratio=1-i/N*0.5;
        r=L/9;
        r=r*ratio;
        var angle=theta+ALPHA;
        var b=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));

        r=L/9*4/Math.cos(BETA);
        r=r*ratio;
        angle=theta+ALPHA+BETA;
        var d=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L/9*4/Math.cos(BETA);
        r=r*ratio;
        angle=theta+ALPHA-BETA;
        var e=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L;
        r=r*ratio;
        angle=theta+ALPHA;
        var c=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));
            
        ctx.fillStyle=color;
        ctx.beginPath();
        ctx.moveTo(a.x,a.y);
        ctx.lineTo(b.x,b.y);
        ctx.quadraticCurveTo(d.x,d.y,c.x,c.y);
        ctx.quadraticCurveTo(e.x,e.y,b.x,b.y);            
        ctx.closePath();            
        ctx.fill();
    }

    // 画内侧叶子
    for(var i=0;i<N;i++){
        var theta=START+STEP*i;
        var r=R;
        var a=createPt(r*Math.cos(theta),r*Math.sin(theta));

        var ratio=1-i/N*0.5;
        
        r=L/9;
        r=r*ratio;
        var angle=theta-ALPHA+Math.PI;
        var b=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));        

        r=L/9*4/Math.cos(BETA);
        r=r*ratio;
        angle=theta-ALPHA+Math.PI+BETA;
        var d=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L/9*4/Math.cos(BETA);
        r=r*ratio;
        angle=theta-ALPHA+Math.PI-BETA;
        var e=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L;
        r=r*ratio;
        angle=theta-ALPHA+Math.PI;
        var c=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));
            
        ctx.fillStyle=color;
        ctx.beginPath();
        ctx.moveTo(a.x,a.y);
        ctx.lineTo(b.x,b.y);
        ctx.quadraticCurveTo(d.x,d.y,c.x,c.y);
        ctx.quadraticCurveTo(e.x,e.y,b.x,b.y);            
        ctx.closePath();            
        ctx.fill();
    }    

    ctx.restore();
}

/*----------------------------------------------------------
函数:画逆时针橄榄枝
x:横坐标
y:纵坐标
r:橄榄枝中心半径
n:叶片对数
start:起始角度
end:中止角度
alpha: 叶片中线到圆弧的角度
beta:叶片中线到圆弧的角度
color:叶片颜色
----------------------------------------------------------*/
function drawRightOliver(ctx,x,y,r,n,start,end,alpha,beta,color){
    const R=r;                // 橄榄枝中心半径
    var   N=n;                // 有N对叶片    
    const START=start;        // 起始角度
    const END=end;            // 中止角度
    const STEP=(END-START)/N;// 步长        
    const ALPHA=alpha;        // 叶片中线到圆弧的角度
    const L=R/8;            // 叶片长度
    const BETA=beta;        // 叶片中线到圆弧的角度
    
    ctx.save();
    ctx.translate(x,y);
    ctx.lineWidth=1;
    ctx.strokeStyle=color;

    // 画中心圈
    ctx.beginPath();
    for(var i=0;i<N;i++){
        var theta=START+STEP*i;
        var r=R;
        var a=createPt(r*Math.cos(theta),r*Math.sin(theta));
        ctx.lineTo(a.x,a.y);            
    }
    ctx.stroke();

    // 画外侧叶子
    for(var i=0;i<N;i++){
        var theta=START+STEP*i;
        var r=R;
        var a=createPt(r*Math.cos(theta),r*Math.sin(theta));
        
        var ratio=0.5+i/N*0.5;
        r=L/9;
        r*=ratio;
        var angle=theta-ALPHA;
        var b=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));

        r=L/9*4/Math.cos(BETA);
        r*=ratio;
        angle=theta-ALPHA+BETA;
        var d=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L/9*4/Math.cos(BETA);
        r*=ratio;
        angle=theta-ALPHA-BETA;
        var e=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L;
        r*=ratio;
        angle=theta-ALPHA;
        var c=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));
            
        ctx.fillStyle=color;
        ctx.beginPath();
        ctx.moveTo(a.x,a.y);
        ctx.lineTo(b.x,b.y);
        ctx.quadraticCurveTo(d.x,d.y,c.x,c.y);
        ctx.quadraticCurveTo(e.x,e.y,b.x,b.y);            
        ctx.closePath();            
        ctx.fill();
    }

    // 画内侧叶子
    for(var i=0;i<N;i++){
        var theta=START+STEP*i;
        var r=R;
        var a=createPt(r*Math.cos(theta),r*Math.sin(theta));
        
        r=L/9;
        var angle=theta+ALPHA-Math.PI;
        var b=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));

        var ratio=0.5+i/N*0.5;

        r=L/9*4/Math.cos(BETA);
        r*=ratio;
        angle=theta+ALPHA-Math.PI+BETA;
        var d=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L/9*4/Math.cos(BETA);
        r*=ratio;
        angle=theta+ALPHA-Math.PI-BETA;
        var e=createPt(b.x+r*Math.cos(angle),b.y+r*Math.sin(angle));

        r=L;
        r*=ratio;
        angle=theta+ALPHA-Math.PI;
        var c=createPt(a.x+r*Math.cos(angle),a.y+r*Math.sin(angle));
            
        ctx.fillStyle=color;
        ctx.beginPath();
        ctx.moveTo(a.x,a.y);
        ctx.lineTo(b.x,b.y);
        ctx.quadraticCurveTo(d.x,d.y,c.x,c.y);
        ctx.quadraticCurveTo(e.x,e.y,b.x,b.y);            
        ctx.closePath();            
        ctx.fill();
    }    

    ctx.restore();
}

/*--------------------------------------------------
函数:绘制正五角星
ctx:绘图上下文
x:五角星中心横坐标
y:五角星中心纵坐标
R:五角星中心到顶点的距离
---------------------------------------------------*/
function draw5Star(ctx,x,y,R){
    var r=R*Math.sin(Math.PI/10)/Math.sin(Math.PI/10*7);
    
    var arr=[0,0,0,0,0,0,0,0,0,0];

    // 顶五点
    for(var i=0;i<5;i++){
        var theta=i*Math.PI/5*2-Math.PI/10;
        var x1=R*Math.cos(theta)+x;
        var y1=R*Math.sin(theta)+y;
        arr[i*2]=createPt(x1,y1);
    }

    // 内五点
    for(var i=0;i<5;i++){
        var theta=i*Math.PI/5*2+Math.PI/10;
        var x1=r*Math.cos(theta)+x;
        var y1=r*Math.sin(theta)+y;
        arr[i*2+1]=createPt(x1,y1);
    }

    ctx.beginPath();
    for(var i=0;i<arr.length;i++){
        ctx.lineTo(arr[i].x,arr[i].y);
    }
    ctx.closePath();
}

/*----------------------------------------------------------
函数:用于绘制实心圆,用途是标记点以辅助作图
ctx:绘图上下文
x:矩形中心横坐标
y:矩形中心纵坐标
r:圆半径
color:填充圆的颜色
----------------------------------------------------------*/
function drawSolidCircle(ctx,x,y,r,color){
    ctx.fillStyle=color;
    ctx.beginPath();
    ctx.arc(x,y,r,0,Math.PI*2,false);
    ctx.closePath();
    ctx.fill();
}

/*----------------------------------------------------------
函数:创建一个二维坐标点
x:横坐标
y:纵坐标
Pt即Point
----------------------------------------------------------*/
function createPt(x,y){
    var retval={};
    retval.x=x;
    retval.y=y;
    return retval;
}

/*----------------------------------------------------------
函数:延时若干毫秒
milliseconds:毫秒数
----------------------------------------------------------*/
function sleep(milliSeconds) {
    const date = Date.now();
    let currDate = null;
    while (currDate - date < milliSeconds) {
        currDate = Date.now();
    } 
}

/*----------------------------------------------------------
函数:书写文字
ctx:绘图上下文
x:横坐标
y:纵坐标
text:文字
font:字体
color:颜色
----------------------------------------------------------*/
function writeText(ctx,x,y,text,font,color){
    ctx.save();
    ctx.textBaseline="middle";
    ctx.textAlign="center";
    ctx.font = font;
    ctx.fillStyle=color;
    ctx.fillText(text,x,y);
    ctx.restore();
}

/*-------------------------------------------------------------
印度人的勤奋不是自发的,而是贫穷和阶级压制迫使的。
他们拼命内卷加班或打螺丝送快递,不是为了追求自己的理想和目标,
而仅仅是为了在大城市有个地方睡,有口吃食能活下去......
--------------------------------------------------------------*/
//-->
</script>

END