博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Javascript] Gradient Fills on the HTML5 Canvas
阅读量:6900 次
发布时间:2019-06-27

本文共 1995 字,大约阅读时间需要 6 分钟。

window.onload = function() {    var canvas = document.getElementById("canvas"),        context = canvas.getContext("2d");    var gradient =context.createLinearGradient(100,100,100,200);    gradient.addColorStop(1,"blue");   // show blue at the bottom    gradient.addColorStop(0,"yellow"); // show yellow on the top        context.fillStyle=gradient;    context.fillRect(100,100,100,100);};

 

window.onload = function() {    var canvas = document.getElementById("canvas"),        context = canvas.getContext("2d");    var gradient =context.createLinearGradient(100,100,100,200);    gradient.addColorStop(1,"blue");   // show blue at the bottom    gradient.addColorStop(0.75, "pink"); //close to the bottom    gradient.addColorStop(0,"yellow"); // show yellow on the top    context.fillStyle=gradient;    context.fillRect(100,100,100,100);};

 

window.onload = function() {    var canvas = document.getElementById("canvas"),        context = canvas.getContext("2d");    var gradient =context.createLinearGradient(100,100,200,100);    gradient.addColorStop(1,"blue");   // show blue at the bottom    gradient.addColorStop(0.75, "pink"); //close to the bottom    gradient.addColorStop(0,"yellow"); // show yellow on the top    context.fillStyle=gradient;    context.fillRect(100,100,100,100);};

 

----------------------------

window.onload = function() {    var canvas = document.getElementById("canvas"),        context = canvas.getContext("2d");    var gradient = context.createRadialGradient(100,100,0,100,100,50);    gradient.addColorStop(0, "white");    gradient.addColorStop(1, "black");    context.fillStyle = gradient;    context.beginPath();    context.arc(100,100,50,0,Math.PI * 2);    context.closePath();    context.fill();};

 

var gradient = context.createRadialGradient(100,100,20,100,100,50);

 

var gradient = context.createRadialGradient(100,100,20,100,100,80);

 

var gradient = context.createRadialGradient(100,100,20,100,100,30);

 

var gradient = context.createRadialGradient(120,80,0,110,90,60);

转载地址:http://egsdl.baihongyu.com/

你可能感兴趣的文章
『左偏树 Leftist Tree』
查看>>
打印菱形
查看>>
因数分解
查看>>
HDU 6092 Rikka with Subset 【dp多重背包】【好题】
查看>>
.NET学习笔记 01
查看>>
MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.3 Displaying Classes in a Layer...
查看>>
Eclipse下egit插件的使用
查看>>
[NOI2017]整数
查看>>
LINUX信息安全系统设计基础第一周学习总结
查看>>
xdebug对php程序性能分析
查看>>
surfaceview 透明
查看>>
osi七层模型
查看>>
转载:深度研习html(二)
查看>>
HA机制下的hadoop配置
查看>>
MySQL 5.5 新增SIGNAL异常处理
查看>>
回档|忠诚2|zkw线段树
查看>>
Away3D引擎学习笔记(二)CameraController相机控制的应用
查看>>
jq获取元素到底部的距离
查看>>
工作总结
查看>>
一个恶心的需求
查看>>