<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用HTML5绘制的一个星空特效图</title>
<style>
canvas{
display: block;border:1px dotted skyblue;
}
body{
font-family: 微软雅黑;
} </style>
</head>
<body>
<h1>用HTML5绘制的一个星空特效图</h1>
<canvas id="canvas" width="" height=""> </canvas>
<script>
var nimo={};
window.onload=function(){
nimo.canvas=document.getElementById('canvas');
nimo.context=nimo.canvas.getContext('2d'); nimo.starBgImg=new Image();
nimo.starBgImg.src='http://sandbox.runjs.cn/uploads/rs/167/znddwgfj/star-bg.jpg';
nimo.starBgImg.onload=function(){ //填充星星背景
nimo.statBg=nimo.context.createPattern(nimo.starBgImg,'repeat')
nimo.context.rect(,,nimo.canvas.width,nimo.canvas.height);
nimo.context.fillStyle=nimo.statBg;
nimo.context.fill(); //绘制月亮轮廓
nimo.context.beginPath();
nimo.context.arc(,,,0.6*Math.PI,1.3*Math.PI);
nimo.context.bezierCurveTo(,,,,,) //填充月亮轮廓和设置投影
nimo.context.shadowColor="blue";
nimo.context.shadowBlur=;
nimo.context.strokeStyle="blue";
nimo.context.stroke(); //填充放射渐变给月亮
nimo.radialGradient=nimo.context.createRadialGradient(,,,,,);
nimo.radialGradient.addColorStop(,'white')
nimo.radialGradient.addColorStop(,'#999')
nimo.context.fillStyle=nimo.radialGradient;
nimo.context.fill() //绘制月亮的研究和嘴巴
nimo.context.shadowColor="white";
nimo.context.beginPath();
nimo.context.moveTo(,);
nimo.context.lineTo(,);
nimo.context.moveTo(,);
nimo.context.lineTo(,);
nimo.context.stroke(); nimo.context.beginPath();
nimo.context.arc(,,,,*Math.PI);
nimo.context.stroke();
nimo.context.shadowColor='transparent';
nimo.context.font="14px 微软雅黑"
nimo.context.fillText('好挫的月亮!',,)
} } </script>
<p>
demo by <a href="http://js.alixixi.com/">js.alixixi.com</a>
</p>
</body>
</html>

用HTML5绘制的一个星空特效图的更多相关文章

  1. JavaScript+svg绘制的一个饼状图

    结果: svg参考:https://www.w3.org/TR/SVG/<body onload='document.body.appendChild( pieChart([12,23,34,4 ...

  2. html5绘制折线图

    html5绘制折线图详细代码 <html> <canvas id="a_canvas" width="1000" height="7 ...

  3. HTML5 Canvas ( 绘制一片星空 )

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. Html5绘制饼图统计图

    这里要介绍的是一个jQuery插件:jquery.easysector.js Html5提供了强大的绘图API,让我们能够使用javascript轻松绘制各种图形.本文将主要讲解使用HTML5绘制饼图 ...

  5. 9款HTML5实现的超酷特效

    之前我们推荐了8款HTML5实现的特效和应用,今天我们带来的这9款热门的HTML5特效同样会带给你全新的视角和体验. HTML5是HTML的升级版,HTML5有两大特点:首先,强化了 Web 网页的表 ...

  6. C#绘制立体三维饼状图

    转载自原文 C#绘制立体三维饼状图(超酷) 内容原文地址:LINK [翻译]Julijan Sribar著3D Pie Chart一个用于绘制立体三维饼状图的C#类库[简介]本文的想法就是创建一个独立 ...

  7. 9款超绚丽的HTML5/CSS3应用和动画特效

    1.CSS3飘带状3D菜单 菜单带小图标 这次我们要来分享一款很特别的CSS3菜单,菜单的外观是飘带状的,并且每一个菜单项有一个精美的小图标,鼠标滑过菜单项时,菜单项就会向上凸起,像是飘带飘动一样,形 ...

  8. 精选7款绚丽的HTML5和jQuery图片动画特效

    在HTML5出现后,图片就变得更加富有动感了,各种图片动画特效也层出不穷,例如图片播放器.图片导航.3D图片动画等等.本文将精选几款具有代表性的HTML5和jQuery图片动画特效,绚丽的画面.实用的 ...

  9. HTML5绘制矩形和圆形并且还有获取在这个图层内的坐标的思路和代码 - feilong_12的专栏 - 博客频道 - CSDN.NET

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...

随机推荐

  1. JSON后台处理特殊字符方法,在JSONArray.fromObject转换时处理

    /** * 替换一个字符串中的某些指定字符 * @param strData String 原始字符串 * @param regex String 要替换的字符串 * @param replaceme ...

  2. xml中Node和Element的区别

    本文转载自:http://blog.csdn.net/wcydiyi/article/details/4432636点击打开链接 1.元素(Element)和结点(Node)的区别:         ...

  3. Python全栈day 05

    Python全栈day 05 一.数据类型补充 1. int py2和py3的2种区别 py2有int和long,int的取值范围为-2^31~2^31-1,超出范围自动转为long,长整型. py2 ...

  4. Color Length UVA - 1625 DP

    题目:题目链接 题意:输入两个长度分别为n和m的颜色序列,要求按顺序合并成同一个序列,即每次可以把一个序列开头的颜色放到新序列的尾部.对于每个颜色c来说,其跨度L(c)等于最大位置和最小位置之差,输出 ...

  5. python-2函数

    http://docs.python.org/3/library/functions.html 或者菜鸟中文资料 1-使用函数 abs(-20)#求绝对值 max(1,4,200,3,2) #求最大的 ...

  6. [WC2002][洛谷P1578]奶牛浴场

    洛谷题解里那个人可真是话多呢. 题目描述 由于John建造了牛场围栏,激起了奶牛的愤怒,奶牛的产奶量急剧减少.为了讨好奶牛,John决定在牛场中建造一个大型浴场.但是John的奶牛有一个奇怪的习惯,每 ...

  7. string函数Contains()实例

    public bool Contains(string value)如果值参数出现在此字符串内,或者值为空字符串(“”),则为true; 否则为false using System; class Ex ...

  8. hbase shell出现ERROR:Can't get master address from Zookeeper;znode data==null

    hbase shell出现ERROR:Can't get master address from Zookeeper;znode data==null(ERROR:org.apache.hadoop. ...

  9. 怎么设置才能让外网ip可以访问mysql数据库[转]

    转自: http://www.hongyanliren.com/89.html 使用mysql中,很多人都会遇到这样的问题:在vps服务器或者云服务器上安装了mysql后,使用其他工具在外网ip之下根 ...

  10. ARC下,不显式指定任何属性关键字时,默认的关键字都有哪些

    1.对应基本数据类型默认关键字是 atomic,readwrite,assign 2.对于普通的 Objective-C 对象 atomic,readwrite,strong