乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      SVG線性漸變色 | WEB知識

       537q60d4uhwd3e 2020-01-10

      漸變色(gradient)是指從一種顏色平滑的過渡到另外一種顏色。而且,我們可以將多種漸變色應(yīng)用到同一個網(wǎng)頁元素上。

      在SVG里,有兩種主要的漸變色類型:

      • 線性漸變色 Linear

      • 輻射式(放射式)漸變色 Radial


      SVG線性漸變色 – <linearGradient>

      <linearGradient>標(biāo)記就是用來定義漸變色的。

      <linearGradient>標(biāo)記必須放在<defs>標(biāo)記內(nèi)。<defs>標(biāo)記就是“definitions”單詞的簡寫,用來容納其它各種SVG標(biāo)記。

      線性漸變色可以定義成水平漸變色,垂直漸變色和斜向漸變色:

      • 當(dāng)y1y2相等,而x1x2不等時,就形成了水平漸變色

      • 當(dāng)y1y2不等,而x1x2相等時,就形成了垂直漸變色

      • 當(dāng)y1y2不等,而x1x2也不等時,就形成了斜向漸變色


      例 1

      我們先定義一個橢圓,而后用一個從黃色到紅色的漸變色渲染它:

      上面的圖像使用了下面的SVG代碼:

      <svg height='150' width='400'> <defs>   <linearGradient id='grad1' x1='0%' y1='0%' x2='100%' y2='0%'>     <stop offset='0%' style='stop-color:rgb(255,255,0);stop-opacity:1' />     <stop offset='100%' style='stop-color:rgb(255,0,0);stop-opacity:1' />   </linearGradient> </defs> <ellipse cx='200' cy='70' rx='85' ry='55'fill='url(#grad1)' /></svg>

      代碼說明:

      • <linearGradient>標(biāo)記的id屬性定義了這個漸變色的唯一標(biāo)志

      • <linearGradient>標(biāo)記的x1, x2, y1,y2四個屬性定義了漸變色的起始位置和終止位置

      • 漸變色的顏色組成可以是2個或2個以上的顏色。每種顏色都使用一個<stop>標(biāo)記定義。offset屬性用來定義漸變色的開始和結(jié)束位置。

      • fill屬性定義了需要引用的漸變色的ID


      例 2

      下面的例子中的漸變色方向是垂直的:

      上面的圖像使用了下面的SVG代碼:

      <svg height='150' width='400'> <defs>   <linearGradient id='grad2' x1='0%' y1='0%' x2='0%' y2='100%'>     <stop offset='0%' style='stop-color:rgb(255,255,0);stop-opacity:1' />     <stop offset='100%' style='stop-color:rgb(255,0,0);stop-opacity:1' />   </linearGradient> </defs> <ellipse cx='200' cy='70' rx='85' ry='55' fill='url(#grad2)' /></svg>

      例 3

      下面的例子里,我們使用了水平漸變色,并且還在橢圓里添加了文字:

      上面的圖像使用了下面的SVG代碼:

      <svg height='150' width='400'> <defs>   <linearGradient id='grad3' x1='0%' y1='0%' x2='100%' y2='0%'>     <stop offset='0%' style='stop-color:rgb(255,255,0);stop-opacity:1' />     <stop offset='100%' style='stop-color:rgb(255,0,0);stop-opacity:1' />   </linearGradient> </defs> <ellipse cx='200' cy='70' rx='85' ry='55'fill='url(#grad3)' />  <text fill='#ffffff' font-size='45' font-family='Verdana' x='150' y='86'>  SVG</text></svg>

      代碼說明:

      • <text>標(biāo)記的作用是添加一段文字




      WEBHEK is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding.Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content.

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多