[ html createLinearGradient createRadialGradient 繪製背景漸層方式 ] canvas繪製漸層 createLinearGradient createRadialGradient 繪製背景漸層方式 屬性執行個體

來源:互聯網
上載者:User

標籤:

 1 <!DOCTYPE html> 2 <html lang=‘zh-cn‘> 3 <head> 4 <title>Insert you title</title> 5 <meta name=‘description‘ content=‘this is my page‘> 6 <meta name=‘keywords‘ content=‘keyword1,keyword2,keyword3‘> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 8 <link rel=‘stylesheet‘ type=‘text/css‘ href=‘./css/index.css‘ /> 9 <script type=‘text/javascript‘ src=‘./js/jquery-1.12.1.min.js‘></script>10 <style type=‘text/css‘>11 html,body {12     margin: 0; padding: 0;13 }14 15 html {16     height: 100%;17 }18 19 body {20     background: #000;21 }22 23 #can {24     display: block; border-radius: 2px; margin: 25px auto; background: #FFF;25 }26 </style>27 <script type=‘text/javascript‘>28     $( function(){29         var oCan = $( ‘#can‘ ).get( 0 ).getContext( ‘2d‘ );30         /* 建立線性漸層方式 */31         //var clg = oCan.createLinearGradient(0,0,500,450);    /* 參數 : 起始點 結束點座標 */32         //clg.addColorStop(.3,‘#F00‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */33         //clg.addColorStop(.5,‘#FF0‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */34         //clg.addColorStop(.7,‘#F0F‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */35         //clg.addColorStop(1,‘#0FF‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */36         //oCan.fillStyle = clg;    /* 填充方式為必備 */37         //oCan.fillRect(0,0,500,450);38         39         /* 建立放射狀漸層的方式於此相同,不在示範... */40         var clg = oCan.createRadialGradient(270,3,70,500,450,5);    /* 參數 : 起始點 結束點座標 半徑值*/41         clg.addColorStop(.3,‘#F00‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */42         clg.addColorStop(.5,‘#FF0‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */43         clg.addColorStop(.7,‘#F0F‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */44         clg.addColorStop(1,‘#0FF‘);    /* 參數 : 起始點座標 0-1 可多個 ,顏色值 */45         oCan.fillStyle = clg;    /* 填充方式為必備 */46         oCan.fillRect(0,0,500,450);47     } );48 </script>49 </head>50 <body>51     <canvas id=‘can‘ width=‘500‘ height=‘450‘>您的瀏覽器版本過低,請升級您的瀏覽器以擷取更好的使用體驗...</canvas>52 </body>53 </html>

 

[ html createLinearGradient createRadialGradient 繪製背景漸層方式 ] canvas繪製漸層 createLinearGradient createRadialGradient 繪製背景漸層方式 屬性執行個體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.