
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、canvas畫的四漸變色播放按鈕效果這篇文章主要介紹了用法javascript和html5 canvas畫的四漸變色播放按鈕效果,需要的伴侶可以參考下是html5浮現(xiàn)的新標簽,像全部的dom對象一樣它有自己本身的屬性、辦法和大事,其中就有繪圖的辦法,js能夠調(diào)用它來舉行繪圖,本文用法canvas標簽和javascript協(xié)作畫出了一個四色漸變的播放按鈕效果。 實現(xiàn)代碼: 復制代碼代碼如下:畫按鈕您的掃瞄器不支持canvas,請升級掃瞄器! var canvas = document.getelementbyid(&39;mycanvas&39;);/*獵取定義的畫布*/var
2、ctx = canvas.getcontext(&39;2d&39;);/*利用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);/構造線變var yellowgrad=_context.createlineargradient(30,0,0,30);y
3、ellowgrad.addcolorstop(0, &39;fccb02&39;);yellowgrad.addcolorstop(0.5, &39;fbf14d&39;);yellowgrad.addcolorstop(1, &39;ffcb02&39;);var bluegrad=_context.createlineargradient(30,0,0,30);bluegrad.addcolorstop(0, &39;2a459c&39;);bluegrad.addcolorstop(0.5, &39;0e7adc&a
4、mp;39;);bluegrad.addcolorstop(1, &39;2a459e&39;);var redgrad=_context.createlineargradient(30,0,0,30);/通過rotate來旋轉(zhuǎn)redgrad.addcolorstop(0, &39;d0372f&39;);redgrad.addcolorstop(0.5, &39;e0675e&39;);redgrad.addcolorstop(1, &39;ce392d&39;);var greengrad=_context.createlin
5、eargradient(30,0,0,30);/通過rotate來旋轉(zhuǎn)greengrad.addcolorstop(0, &39;059700&39;);greengrad.addcolorstop(0.5, &39;02e003&39;);greengrad.addcolorstop(1, &39;019a02&39;); /繪制兩弧夾角內(nèi)容drawcake(_context,0,yellowgrad,nradius);drawcake(_context,math.pi/2,bluegrad,nradius);drawcake(_context
6、,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, &39;4672df&39;);lingrad.addcolorstop(0.2, &39;6188e5&39;);lingrad.addcolorstop(0.5, &39;98b1ef&39;);lingrad.addcol
7、orstop(0.8, &39;b1c3f2&39;);lingrad.addcolorstop(1, &39;eaedfc&39;);_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.createlineargradi
8、ent(-6,-10,-6,10);trianglerad.addcolorstop(0, &39;99d4ea&39;);trianglerad.addcolorstop(0.2, &39;5e8fdd&39;);trianglerad.addcolorstop(0.5, &39;0f17a1&39;);trianglerad.addcolorstop(0.8, &39;4c65cc&39;);trianglerad.addcolorstop(1, &39;7299e5&39;);_context.beginpa
9、th();_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.lin
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 飲食安全管理制度高校
- 街區(qū)培訓運營管理制度
- 公司小浴室管理制度
- 鑄造車間節(jié)能管理制度
- 銷售品質(zhì)閉環(huán)管理制度
- 蜂蜜公司財務管理制度
- 高校班級班費管理制度
- 黃金交易風險管理制度
- 要實施規(guī)范化管理制度
- 酒店女生寢室管理制度
- 蒙古語中的時間表達方式研究論文
- (一模)南京市、鹽城市2025屆高三年級第一次模擬考試歷史試卷(含官方答案)
- 2025年焦作工貿(mào)職業(yè)學院單招職業(yè)技能考試題庫附答案
- 2025年塔里木職業(yè)技術學院單招職業(yè)技能測試題庫完美版
- 清明節(jié)假期安全教育主題班會 課件
- 倒閘操作考試試題及答案
- 專題5 壓強 2021年和2022年四川省成都市中考物理模擬試題匯編
- 【數(shù)學】三角形 問題解決策略:特殊化課件2024-2025學年北師大版數(shù)學七年級下冊
- 國網(wǎng)十八項反措(修訂版)宣貫
- (高清版)DB21∕T 2481-2015 水利工程單元工程施工質(zhì)量檢驗與評定標準-農(nóng)村水利工程
- 消防技術標準的解讀與應用實例
評論
0/150
提交評論