canvas(三) star- demo
- /**
- * Created by xianrongbin on 2017/3/8.
- * 本例子使用渐变画出 璀璨星空
- */
- var dom = document.getElementById('clock'),
- ctx = dom.getContext('2d'),
- cirucle = Math.PI;
- //ctx.lineJoin='miter'; //round 圆角 bevel 斜角 miter尖角
- //ctx.miterLimit=150;//默认10 只有当 lineJoin=miter,当超过这个度数,会变成bevel,只有显示十分尖锐的角,才会修改
- /*var skyStyle=ctx.createLinearGradient(0,0,0,ctx.canvas.height);*/
- var skyStyle=ctx.createRadialGradient(dom.width/,dom.height/,,dom.width/,ctx.canvas.height,ctx.canvas.height);
- skyStyle.addColorStop(0.0,'#035');
- skyStyle.addColorStop(1.0,'black');
- ctx.fillStyle =skyStyle; //填充天边渐变色
- ctx.fillRect(, , ctx.canvas.width, ctx.canvas.height);
- ctx.fill();
- /**
- *
- * @param ctx 画布上下文
- * @param r 内圆半径
- * @param R 外圆半径
- * @param x 横向偏移量
- * @param y 纵向偏移量
- * @param rot 选择度数
- */
- function drawStar(ctx, x, y, outerR, innerR, rot) {
- ctx.beginPath();
- for (var i = ; i < ; i++) {
- var ourRad = ( + i * - rot) / * cirucle,
- innerRad = ( + i * - rot) / * cirucle;
- ctx.lineTo(Math.cos(ourRad) * outerR + x,
- -Math.sin(ourRad) * outerR + y);
- ctx.lineTo(Math.cos(innerRad) * innerR + x,
- -Math.sin(innerRad) * innerR + y);
- }
- ctx.closePath();
- ctx.fillStyle = '#c1c';
- ctx.strokeStyle = '#fd5';
- ctx.lineWidth = ;
- ctx.stroke();
- ctx.fill();
- }
- for (var i = ; i < ; i++) {
- var r = Math.random() * + ,//Math.random() 生产10-20随机数
- x = Math.random() * dom.width,
- y = Math.random() * dom.height*0.65,
- a =Math.random() * ;
- drawStar(ctx, x, y, r, r / 2.0, a);
- }
canvas(三) star- demo的更多相关文章
- HTML5 之Canvas 绘制时钟 Demo
<!DOCTYPE html> <html> <head> <title>Canvas 之 时钟 Demo</title> <!--简 ...
- SignalR代理对象异常:Uncaught TypeError: Cannot read property 'client' of undefined 推出的结论 SignalR 简单示例 通过三个DEMO学会SignalR的三种实现方式 SignalR推送框架两个项目永久连接通讯使用 SignalR 集线器简单实例2 用SignalR创建实时永久长连接异步网络应用程序
SignalR代理对象异常:Uncaught TypeError: Cannot read property 'client' of undefined 推出的结论 异常汇总:http://www ...
- canvas画箭头demo
效果图: 代码: <!DOCTYPE html> <html> <title>canvas画箭头demo</title> <body> &l ...
- 通过三个DEMO学会SignalR的三种实现方式
一.理解SignalR ASP .NET SignalR 是一个ASP .NET 下的类库,可以在ASP .NET 的Web项目中实现实时通信(即:客户端(Web页面)和服务器端可以互相实时的通知消息 ...
- SignalR的三个Demo
一.理解SignalR ASP .NET SignalR 是一个ASP .NET 下的类库,可以在ASP .NET 的Web项目中实现实时通信(即:客户端(Web页面)和服务器端可以互相实时的通知消息 ...
- Flutter 36: 图解自定义 View 之 Canvas (三)
小菜继续学习 Canvas 的相关方法: drawVertices 绘制顶点 小菜上次没有整理 drawVertices 的绘制方法,这次补上:Vertice 即顶点,通过绘制多个顶点,在进行连线,多 ...
- 通过三个DEMO学会SignalR的三种实现方式 转载https://www.cnblogs.com/zuowj/p/5674615.html
一.理解SignalR ASP .NET SignalR 是一个ASP .NET 下的类库,可以在ASP .NET 的Web项目中实现实时通信(即:客户端(Web页面)和服务器端可以互相实时的通知消息 ...
- canvas 画圈 demo
html代码: <canvas id="clickCanvas2" width="180" height="180" data-to ...
- RobotFrameWork接口报文测试-----(三)demo的加强版(数据驱动测试)
在上一篇RobotFrameWork接口报文测试-----(二)demo的升级版基础上,将接口的xml的格式保存在xml文件中,然后程序如果增加一个接口,在xml文件里添加即可,无需修改自动化测试里的 ...
- html 5 canvas 绘制太极demo
一个练习canvas的小案例.其中若有小问题,欢迎大神拍砖……^_* 代码效果预览地址:http://code.w3ctech.com/detail/2500. <div class=" ...
随机推荐
- Spring事务原理
Spring事务的本质是对数据库事务的封装支持,没有数据库对事务的支持,Spring本身无法提供事务管理功能.对于用JDBC操作数据库想要用到事务,必须经过获取连接——>开启事务——>执行 ...
- 第一章 HTML+CSS(中)
4.域元素(form表单.textarea文本域.fieldset域集合.input使用) 案例 表单 用户名: 密码: 昵称: 你喜欢的水果有? 苹果 黄瓜 香蕉 请选择性别 男 女 请选择你要的网 ...
- Zookeeper的下载、安装和启动
一.下载Zookeeper 版本 zookeeper-3.4.13 下载地址:https://archive.apache.org/dist/zookeeper/ 解压后放在/usr/local/zo ...
- C++笔记(1)
C++笔记1文件与流笔记 参考博客: https://blog.csdn.net/kingstar158/article/details/6859379 关闭文件中: 当文件读写操作完成之 ...
- win10+vs2015编译caffe的cpu debug版本、部署matcaffe
一.编译caffe 1.安装python-3.5.2-amd64.exe https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe ...
- 【idea】之使用SVN一些技巧
@Copy https://www.cnblogs.com/whc321/p/5669804.html
- Android之微信布局篇
一.准备工作: 1. 下载好相关的图片: 2.创建一个名WeiChat的项目,将图片复制到res----->drawable-hdpi目录下. 二.编写代码: 1. 最终效果: 2.微信可划分为 ...
- Kong管理UI -kong-dashboard
本文仍然是在ubuntu18的环境下进行 https://github.com/PGBI/kong-dashboard kong dashboart如果要正常使用管理UI,前提为kong已经正常run ...
- Prometheus介绍
Prometheus的主要特点 Prometheus 属于一站式监控告警平台,依赖少,功能齐全.Prometheus 支持对云的或容器的监控,其他系统主要对主机监控.Prometheus 数据查询语句 ...
- kafka的log存储解析——topic的分区partition分段segment以及索引等(转发)
原文 https://www.cnblogs.com/dorothychai/p/6181058.html 引言 Kafka中的Message是以topic为基本单位组织的,不同的topic之间是相互 ...