html5 canvas 画hello ketty

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html5 canvas 画hello ketty相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>Html5 - 小猫咪</title>
    <link rel="stylesheet" type="text/css" href="css/common/reset.css"/>
    <style>
        body{text-align: center;}
        .wrapper{ height:800px;}
        canvas{ margin-top: 123px;}
    </style>
</head>
<body>
    <div class="wrapper">
        <canvas width="600" height="554"></canvas>
    </div>

    <script>
        var cvs=document.querySelector("canvas");
        var g=cvs.getContext("2d");
        
        //尾巴
        g.strokeStyle="#33190c";
        g.fillStyle="#ffffd9";
        g.lineWidth=6;
        g.beginPath();
          g.moveTo(433,458);
          g.lineTo(477,438);
          g.bezierCurveTo(492,433,496,453,484,463);
          g.lineTo(433,494);
        g.fill();
        g.stroke();

        //身体
        g.beginPath();
          g.moveTo(255,392);
          g.lineTo(255,526);
          g.bezierCurveTo(256,555,282,557,293,530);
          g.lineTo(383,530);
          g.bezierCurveTo(392,557,419,558,428,526);
          g.quadraticCurveTo(434,523,430,393);
        g.closePath();
        g.fill();
        g.stroke();
        //肚白
        g.fillStyle="#fff";
        g.beginPath();
          g.moveTo(317,501);
          g.quadraticCurveTo(345,504,363,500);
          g.quadraticCurveTo(386,492,389,480);
          g.quadraticCurveTo(393,469,396,437);
        g.closePath();
        g.fill();
        //肚子蓝点
        g.fillStyle="#e5f8ef";
        g.beginPath();
          g.moveTo(428,459);
          g.bezierCurveTo(407,456,405,479,421,482);
          g.bezierCurveTo(393,482,394,507,427,511);
          g.quadraticCurveTo(429,485,428,459);
        g.closePath();
        g.fill();

        //耳朵(左边)
        g.strokeStyle="#33190c";
        g.fillStyle="#ffffd9";
        g.lineWidth=4;
        g.beginPath();
          g.moveTo(106,79);
          g.quadraticCurveTo(114,4,209,14);
        g.fill();
        g.stroke();
        //耳朵(右边)
        g.beginPath();
          g.lineWidth=5;
          g.moveTo(376,14);
          g.quadraticCurveTo(431,13,446,15);
          g.quadraticCurveTo(488,20,498,48);
          g.quadraticCurveTo(508,75,512,110);
        g.fill();
        g.stroke();

        g.beginPath();
          g.lineWidth=8;
          g.moveTo(470,65);
          g.lineTo(483,27);
        g.stroke();

        g.beginPath();
          g.fillStyle="#fecce5";
          g.moveTo(473,65);
          g.lineTo(483,30);
          g.bezierCurveTo(502,46,496,60,512,110);
        g.closePath();
        g.fill();

        //
        g.lineWidth=10;
        g.beginPath();
          g.strokeStyle="#33190c";
          g.fillStyle="#ffffd9";
          g.moveTo(280,6);
          g.bezierCurveTo(476,0,535,154,541,166);
          g.lineTo(546,180);
          g.bezierCurveTo(584,304,530,368,432,392);
          g.quadraticCurveTo(210,460,90,372);
          g.quadraticCurveTo(38,324,34,314);
          g.quadraticCurveTo(1,268,38,174);
          g.quadraticCurveTo(128,8,280,6);
        g.closePath();
        g.fill();
        g.stroke();

        //脸白
        g.fillStyle="#fff";
        g.beginPath();
          g.moveTo(29,294);
          g.quadraticCurveTo(57,339,99,371);
          g.quadraticCurveTo(272,404,427,390);
          g.bezierCurveTo(500,371,567,330,549,216);
          g.bezierCurveTo(560,298,518,360,427,378);
          g.quadraticCurveTo(272,404,99,364);
          g.quadraticCurveTo(55,334,29,294);
        g.closePath();
        g.fill();

        //胡须(左边)
        g.strokeStyle="#33190c";
        g.lineWidth=7;
        g.beginPath();
          g.moveTo(6,212);
          g.lineTo(23,212);
          g.stroke();
          g.moveTo(7,211);
          g.quadraticCurveTo(5,212,7,213);
        g.stroke();

        g.beginPath();
          g.moveTo(2,246);
          g.lineTo(15,246);
          g.stroke();
          g.moveTo(6,245);
          g.quadraticCurveTo(1,246,6,247);
        g.stroke();

        g.beginPath();
          g.moveTo(6,284);
          g.lineTo(17,281);
          g.stroke();
          g.moveTo(9,282);
          g.quadraticCurveTo(4,287,6,282);
        g.stroke();
        //胡须(右边边)
        g.lineWidth=6;
        g.beginPath();
          g.moveTo(529,233);
          g.lineTo(596,246);
          g.stroke();
          g.moveTo(530,233);
          g.quadraticCurveTo(528,233,530,234);
          g.stroke();
          g.moveTo(596,246);
          g.quadraticCurveTo(597,246,596,246);
        g.stroke();

        g.beginPath();
          g.moveTo(525,263);
          g.lineTo(587,290);
          g.stroke();
          g.moveTo(526,263);
          g.quadraticCurveTo(524,263,527,264);
          g.stroke();
          g.moveTo(587,290);
          g.quadraticCurveTo(589,291,587,290);
        g.stroke();

        g.beginPath();
          g.moveTo(523,296);
          g.lineTo(581,331);
          g.stroke();
          g.moveTo(524,298);
          g.quadraticCurveTo(522,294,524,297);
          g.stroke();
          g.moveTo(581,331);
          g.quadraticCurveTo(583,332,581,331);
        g.stroke();

        //眉毛(左边)
        g.lineWidth=5;
        g.beginPath();
          g.moveTo(163,40);
          g.lineTo(182,42);
          g.moveTo(182,42);
          g.quadraticCurveTo(185,42,180,42);
        g.stroke();
        //眉毛(右边)
        g.beginPath();
          g.moveTo(374,54);
          g.quadraticCurveTo(386,43,396,57);
          g.moveTo(375,54);
          g.quadraticCurveTo(372,56,376,53);
          g.moveTo(395,56);
          g.quadraticCurveTo(397,58,395,56);
        g.stroke();

        //额头蓝点
        g.fillStyle="#e5f8ef";
        g.beginPath();
          g.moveTo(190,30);
          g.bezierCurveTo(180,57,216,65,218,20);
          g.quadraticCurveTo(203,23,190,30);
        g.closePath();
        g.fill();
        g.beginPath();
          g.moveTo(239,15);
          g.bezierCurveTo(233,70,280,60,278,11);
          g.quadraticCurveTo(257,11,239,15);
        g.closePath();
        g.fill();
        g.beginPath();
          g.moveTo(304,11);
          g.bezierCurveTo(285,48,329,74,339,15);
          g.quadraticCurveTo(322,11,304,11);
        g.closePath();
        g.fill();
        g.beginPath();
          g.moveTo(365,20);
          g.bezierCurveTo(354,47,380,53,389,28);
          g.quadraticCurveTo(378,23,366,20);
        g.closePath();
        g.fill();

        //腮红(左边)
        g.fillStyle="#ffcce6";
        g.beginPath();
          g.moveTo(110,199);
          g.quadraticCurveTo(73,179,47,198);
          g.bezierCurveTo(41,204,43,211,47,215);
          g.quadraticCurveTo(73,235,120,212);
        g.closePath();
        g.fill();
        //腮红(右边)
        g.beginPath();
          g.moveTo(428,200);
          g.quadraticCurveTo(470,186,507,210);
          g.bezierCurveTo(519,218,514,240,497,244);
          g.quadraticCurveTo(454,256,420,227);
        g.closePath();
        g.fill();
        //害羞(左边)
        g.strokeStyle="#361909";
        g.lineWidth以上是关于html5 canvas 画hello ketty的主要内容,如果未能解决你的问题,请参考以下文章

你好 你的这个问题 “ html5 canvas 中用鼠标画(拉出)直线的问题! ”

html5 canvas 画圆弧有锯齿怎么解决

android html5 canvas 为啥不捕获画线?

玩转 html5 ---- 用 canvas 结合脚本在画布上画简单的图 (html5 又一强大功能)

html5 canvas 画一个矩形,在矩形里添加文字。 文字颜色与矩形背景颜色有关问题?

html5 js canvas中画星星的函数