茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    使用javascript和HTML5 Canvas畫的四漸變色播放按鈕效果
    來源:易賢網(wǎng) 閱讀:1436 次 日期:2016-07-11 10:10:15
    溫馨提示:易賢網(wǎng)小編為您整理了“使用javascript和HTML5 Canvas畫的四漸變色播放按鈕效果”,方便廣大網(wǎng)友查閱!

    <canvas></canvas>是html5出現(xiàn)的新標(biāo)簽,像所有的dom對象一樣它有自己本身的屬性、方法和事件,其中就有繪圖的方法,js能夠調(diào)用它來進行繪圖,本文使用canvas標(biāo)簽和Javascript配合畫出了一個四色漸變的播放按鈕效果,效果圖:

    名單

    實現(xiàn)代碼:

    代碼如下:

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=gbk">

    <title>畫按鈕</title>

    </head>

    <body>

    <canvas id="myCanvas" width="600" height="400">您的瀏覽器不支持Canvas,請升級瀏覽器!</canvas>

    <script type = "text/javascript" >

    var canvas = document.getElementById('myCanvas');/*獲取定義的畫布*/

    var ctx = canvas.getContext('2d');/*利用2維環(huán)境中進行繪畫*/

    drawPlayButton(ctx,200,200);

    drawPlayButton(ctx,400,200);

    drawPlayButton(ctx,300,200);

    function drawPlayButton(_context,x,y){

    var nRadius=30;//半徑

    _context.save();

    _context.translate(x,y);

    //構(gòu)造線變

    var yellowGrad=_context.createLinearGradient(30,0,0,30);

    yellowGrad.addColorStop(0, '#fccb02');

    yellowGrad.addColorStop(0.5, '#fbf14d');

    yellowGrad.addColorStop(1, '#ffcb02');

    var blueGrad=_context.createLinearGradient(30,0,0,30);

    blueGrad.addColorStop(0, '#2a459c');

    blueGrad.addColorStop(0.5, '#0e7adc');

    blueGrad.addColorStop(1, '#2a459e');

    var redGrad=_context.createLinearGradient(30,0,0,30);//通過rotate來旋轉(zhuǎn)

    redGrad.addColorStop(0, '#d0372f');

    redGrad.addColorStop(0.5, '#e0675e');

    redGrad.addColorStop(1, '#ce392d');

    var greenGrad=_context.createLinearGradient(30,0,0,30);//通過rotate來旋轉(zhuǎn)

    greenGrad.addColorStop(0, '#059700');

    greenGrad.addColorStop(0.5, '#02e003');

    greenGrad.addColorStop(1, '#019a02');

    //繪制兩弧夾角內(nèi)容

    drawCake(_context,0,yellowGrad,nRadius);

    drawCake(_context,Math.PI/2,blueGrad,nRadius);

    drawCake(_context,Math.PI,redGrad,nRadius);

    drawCake(_context,3*Math.PI/2,greenGrad,nRadius);

    //內(nèi)圓顏色

    var lingrad =_context.createLinearGradient(-30,-30,30,30);

    lingrad.addColorStop(0, '#4672df');

    lingrad.addColorStop(0.2, '#6188e5');

    lingrad.addColorStop(0.5, '#98b1ef');

    lingrad.addColorStop(0.8, '#b1c3f2');

    lingrad.addColorStop(1, '#eaedfc');

    _context.save();

    _context.beginPath();//內(nèi)圓

    _context.fillStyle=lingrad;

    _context.arc(0,0,nRadius-10,0,Math.PI*2,true);

    _context.fill();

    _context.closePath();

    _context.restore();

    //繪制三角

    var trianglerad=_context.createLinearGradient(-6,-10,-6,10);

    trianglerad.addColorStop(0, '#99d4ea');

    trianglerad.addColorStop(0.2, '#5e8fdd');

    trianglerad.addColorStop(0.5, '#0f17a1');

    trianglerad.addColorStop(0.8, '#4c65cc');

    trianglerad.addColorStop(1, '#7299e5');

    _context.beginPath();

    _context.fillStyle=trianglerad;

    _context.moveTo(12,0);

    _context.lineTo(-6,10);

    _context.lineTo(-6,-10);

    _context.fill();

    _context.restore();

    }

    //繪畫一個扇形

    function drawCake(_context,_nRotateAngle,_fillColor,_nRadius){

    _context.save();

    _context.beginPath();

    _context.fillStyle=_fillColor;

    _context.rotate(_nRotateAngle);

    _context.moveTo(_nRadius-10,0);

    _context.lineTo(_nRadius,0);//向右畫一根線

    _context.arc(0,0,_nRadius,0,Math.PI/2,false);

    _context.lineTo(0,_nRadius-10);//向上畫一個

    _context.arc(0,0,_nRadius-10,Math.PI/2,0,true); //逆時針畫內(nèi)弧

    _context.fill();

    _context.closePath();

    _context.restore();

    }

    </script>

    </body>

    </html>

    更多信息請查看網(wǎng)頁制作
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)